T
Tim Colton
I have a web form which has a textbox, required field validator, and a submit button. If the web form inherits from System.Web.UI.Page everything works as expected. If you leave the textbox blank and click on the button, the client-side validation code runs, displays the error text and prevents the postback
If the page inherits from a intermediate class the validation code does not run. The intermediate class inherits from System.Web.UI.Page. In the class I wrap the contents of the web form HTML control with a panel control using the following code
//Surround the existing content with a pane
foreach (Control currentControl in Page.Controls
if (currentControl.GetType().ToString() == "System.Web.UI.HtmlControls.HtmlForm"
//Move the existing controls to a panel; this process "breaks" the client-sid
//validation. The input button no longer calls the client-side validation script
Panel myPanel = new Panel()
while (currentControl.Controls.Count > 0
myPanel.Controls.Add(currentControl.Controls[0])
//Attach the panel to the current contro
currentControl.Controls.Add(myPanel)
When I compare the browser HTML source the difference between the working and non-working scenarios involves the onclick attribute of the button. In the non-working case, there is no onclick attribute pointing to the validation javascript
The validation script is there; it's just not "wired up" to the button
How (or when) does the onclick attribute get set? Do I need to do something to get the proper onclick attribute? Thanks in advance for suggestions.
If the page inherits from a intermediate class the validation code does not run. The intermediate class inherits from System.Web.UI.Page. In the class I wrap the contents of the web form HTML control with a panel control using the following code
//Surround the existing content with a pane
foreach (Control currentControl in Page.Controls
if (currentControl.GetType().ToString() == "System.Web.UI.HtmlControls.HtmlForm"
//Move the existing controls to a panel; this process "breaks" the client-sid
//validation. The input button no longer calls the client-side validation script
Panel myPanel = new Panel()
while (currentControl.Controls.Count > 0
myPanel.Controls.Add(currentControl.Controls[0])
//Attach the panel to the current contro
currentControl.Controls.Add(myPanel)
When I compare the browser HTML source the difference between the working and non-working scenarios involves the onclick attribute of the button. In the non-working case, there is no onclick attribute pointing to the validation javascript
The validation script is there; it's just not "wired up" to the button
How (or when) does the onclick attribute get set? Do I need to do something to get the proper onclick attribute? Thanks in advance for suggestions.