I am using Ajax to establish if the client browser supports HTML5 and put this information in a session variable for use during the session. Necessarily, I am writing the code programmatically, not declaratively.
The javascript function stores the HTML5 information in a hidden control and then clicks a hidden button (style="display:none") which calls the click event which moves the information from the hidden control to a session variable.
In my simple test page, which works successully, the html generated for the hidden button is:
Using exactly the same code in my production page, which uses a master page and a wizard, it doesn't work. The html generated for the hidden button is:
The same as in the test page except for the addition of the onclick attribute.
Is the addition of the onclick attribute preventing the code from working correctly? If so, how do I stop the onclick attribute from being generated but still allow the javascript function to fire the submit?
If this is not the cause, how do I fix this problem?
If I use the WebForm_DoPostBackWithOptions() function to make the call, the hidden control loses its value during the postback and i cannot fathom why.
Why is the onclick function generated in my production code. It is not generated in the test code and that works successfully. How to I inhibit the generation of the WebForm_DoPostBackWithOptions() function in the programmatically generated button control?
Is there absolutely anything different between the deployed masterpage and non deployed? It looks though that the input control that is giving errors has the runat="server" attribute set on it. If that's the case then it would be generating calles to WebForm_DoPostBackWithOptions.
Another giveaway though is the fact that the ID of the contorl is: ctl00_Main_btn1 and the name: ctl00$Main$btn1. This would lead me to believe it has runat="server" on it because those id's are the standard format for a server control generating a unique
id for the control on the page.
Don't forget to mark useful responses as Answer if they helped you towards a solution.
rogerwithnel...
Member
65 Points
275 Posts
Inhibit the generation of an onclick attribute
Feb 21, 2012 06:50 PM|LINK
I am using Ajax to establish if the client browser supports HTML5 and put this information in a session variable for use during the session. Necessarily, I am writing the code programmatically, not declaratively.
The javascript function stores the HTML5 information in a hidden control and then clicks a hidden button (style="display:none") which calls the click event which moves the information from the hidden control to a session variable.
In my simple test page, which works successully, the html generated for the hidden button is:
Using exactly the same code in my production page, which uses a master page and a wizard, it doesn't work. The html generated for the hidden button is:
The same as in the test page except for the addition of the onclick attribute.
Is the addition of the onclick attribute preventing the code from working correctly? If so, how do I stop the onclick attribute from being generated but still allow the javascript function to fire the submit?
If this is not the cause, how do I fix this problem?
Your help would be much appreciated.
Thanking you in anticipation.
Roger
Mauro_net
Contributor
2114 Points
402 Posts
Re: Inhibit the generation of an onclick attribute
Feb 21, 2012 06:59 PM|LINK
what if you avoid the button at all and have your javascriptf call directly the "WebForm_DoPostBackWithOptions()" ?
rogerwithnel...
Member
65 Points
275 Posts
Re: Inhibit the generation of an onclick attribute
Feb 22, 2012 10:46 PM|LINK
Thanks for your reply.
If I use the WebForm_DoPostBackWithOptions() function to make the call, the hidden control loses its value during the postback and i cannot fathom why.
Why is the onclick function generated in my production code. It is not generated in the test code and that works successfully. How to I inhibit the generation of the WebForm_DoPostBackWithOptions() function in the programmatically generated button control?
Much appreciate your help.
Roger
markfitzme
Star
14433 Points
2227 Posts
Re: Inhibit the generation of an onclick attribute
Feb 22, 2012 10:57 PM|LINK
Is there absolutely anything different between the deployed masterpage and non deployed? It looks though that the input control that is giving errors has the runat="server" attribute set on it. If that's the case then it would be generating calles to WebForm_DoPostBackWithOptions. Another giveaway though is the fact that the ID of the contorl is: ctl00_Main_btn1 and the name: ctl00$Main$btn1. This would lead me to believe it has runat="server" on it because those id's are the standard format for a server control generating a unique id for the control on the page.