Validation in User Controls used with Master Pages

G

Guest

Hi,
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.

Dan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top