469,570 Members | 1,717 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,570 developers. It's quick & easy.

Validation in User Controls used with Master Pages

In my ASP.NET 2.0 web app, I have a user control, ucBinEdges, with several
text boxes. The user control has several validation controls validating the
Text of these text boxes - CompareValidator, RangeValidator,
RequiredFieldValidator, and a ValidationSummary. The page using ucBinEdges
is a content page working in conjunction with a master page. The master page
defines two ContentPlaceHolders: cphLeftNav and cphReportContent. ucBinEdges
is placed in cphLeftNav. The other content area, cphReportContent, contains
a bunch of other ASP.NET controls.

There are several problems:

1. After adding the validation controls to ucBinEdges, the contents of
cphReportContent do not render to the browser. However, if I add
EnableClientScript="false" to each of the validation controls, everything
displays correctly. Of course, now the validation does not occur
client-side, but only on a postback.

2. Living with only server-side validation for the moment, the validation
occurs *after* the user control Page_Load and TextBox TextChanged event
handlers are fired. This means that code which depends on valid values blows
up. For example, the following line raises an exception if the the Text
property is "abc":
AmountBinMin = Convert.ToInt32(txtMin.Text)

3. OK, so I wrapped the potentially offending lines in a try block, an
inelegant hack at best. Now the validation works fine. Except I am back to
the problem where the contents of cphReportContent do not display when the
page posts back.

4. Finally, if the user corrects the invalid value in the text box and
clicks on a button in cphLeftNav, the following exception is raised:
Invalid postback or callback argument. ... blah blah blah ... use the
ClientScriptManager.RegistserForEventValidation method in order to register
the postback or callback for data validation.

Anybody know what is going on here? It seems the best solution would be to
get the client-side validation working. Failing that, I will probably have
to remove the validation controls entirely and do the data validation myself.

Thanks for any suggestions.

Sep 8 '06 #1
0 1542

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by AIM48 | last post: by
1 post views Thread by Rob R. Ainscough | last post: by
9 posts views Thread by J055 | last post: by
reply views Thread by robgallen | last post: by
10 posts views Thread by Cirene | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.