By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,997 Members | 1,470 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,997 IT Pros & Developers. It's quick & easy.

button to only execute javascript and not postback (using code behind)

P: n/a
I want to create a button using code-behind that only executes javascript,
and does not post back to the server.

How can I do this - my ImageButton insists on posting back to the server.

Thank you
Nov 18 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Joe
Hmmmm, you could check out the autopostback attribute or set the
autopostback property of your button to false if you are building it in a
codebehind.

Joe
"Marcel Balcarek" <ma*************@REM-OVEMEtoxicall.com> wrote in message
news:u1**************@tk2msftngp13.phx.gbl...
I want to create a button using code-behind that only executes javascript,
and does not post back to the server.

How can I do this - my ImageButton insists on posting back to the server.

Thank you

Nov 18 '05 #2

P: n/a
hi,
any javascript run in the (client) onclick event of an
asp.net button will fire before any server side code, and
can prevent a postback to the server if you "return
false;" from the javascript.

alex
-----Original Message-----
I want to create a button using code-behind that only executes javascript,and does not post back to the server.

How can I do this - my ImageButton insists on posting back to the server.
Thank you
.

Nov 18 '05 #3

P: n/a
Thanks Joe, and Alex

Unfortunately, in my VB .NET the imagebutton does not have an autopostback
property / attribute.

The following works:

1) return false from the javascript call

Me.BoldImageButton.Attributes.Add("onclick",
"javascript:FormatText('testiframe', 'bold', '');return false")

2) ensure that the form does NOT have an onsubmit, as this will execute

<form id="Form1" onsubmit="return submitForm();" method="post"
runat="server"> -->

Thank you for your help.

Marcel

"Marcel Balcarek" <ma*************@REM-OVEMEtoxicall.com> wrote in message
news:u1**************@tk2msftngp13.phx.gbl...
I want to create a button using code-behind that only executes javascript,
and does not post back to the server.

How can I do this - my ImageButton insists on posting back to the server.

Thank you

Nov 18 '05 #4

P: n/a
Why not just make it a simple HTML input button if you
don't need to post data back?

Bin Song
MCP
-----Original Message-----
I want to create a button using code-behind that only executes javascript,and does not post back to the server.

How can I do this - my ImageButton insists on posting back to the server.
Thank you


Nov 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.