RichardFox
asked on
Button that doesn't post back, but has onchange javascript function
I want to have a button that looks like a button, but doesn't post back to the server... so I guess I couldn't really call it a button. I have a button control with
addTransBTN.Attributes.Add ("onclick" ,"openNewW in();");
but it still posts back to the server when clicked, causing my page to reload. Do I use a different control, or how does one normally work around this?
addTransBTN.Attributes.Add
but it still posts back to the server when clicked, causing my page to reload. Do I use a different control, or how does one normally work around this?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you want it to run codebehind richardfox it needs to be a server control as Baan said.
BUT a server control will cause a postback.
If the name of the control is Button1, put this code in your page_load
Button1.AutoPostBack = False
BUT a server control will cause a postback.
If the name of the control is Button1, put this code in your page_load
Button1.AutoPostBack = False
No.. gspronych , if it is an HTML control.. it won't.
ASKER
I need to create these controls dynamically. I understand the suggestion, but I need to add the HTML button when I create the rest of my controls, so I can't drag it from the toolbox and right click it and specify "Run at server". How can I do this from code?
ASKER
I created a dynamic control
HtmlControls mybutton;
and set the onclick function, works great, thanks!
HtmlControls mybutton;
and set the onclick function, works great, thanks!
ASKER