By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,002 Members | 2,157 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,002 IT Pros & Developers. It's quick & easy.

Validating Dynamically Loaded User Controls

P: n/a
I have a ASPX page that loads a custom control. This first custom
control is made up of 2 textboxes and a Submit button. The user enters
data into the form, presses the Submit button and the ASPX page should
either load a new custom control during the postback or (if validation
fails) reload the first custom control. I've attached some validation
controls without a problem but the client-side validation doesn't seem
to be working...even in IE with Javascript enabled.

Does anyone have any suggestions? Thanks!

Nov 19 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
ASP.NET pages expect you to create the same list of controls on post back
that you sent to the browser originally. This allows the post back code
distribute the data to those controls and fire their events (including
Click, TextChanged, and validation). It sounds like you aren't setting
things up the same on each pass.

I recommend this:
Load both UserControls. Change their Visibility. On the first pass,
UserControl 2 should be invisible. On the second pass, during the Click even
method, first test that validation was OK (Page.IsValid=true), then change
the visibility of these Usercontrols.

--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

<br********@yahoo.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
I have a ASPX page that loads a custom control. This first custom
control is made up of 2 textboxes and a Submit button. The user enters
data into the form, presses the Submit button and the ASPX page should
either load a new custom control during the postback or (if validation
fails) reload the first custom control. I've attached some validation
controls without a problem but the client-side validation doesn't seem
to be working...even in IE with Javascript enabled.

Does anyone have any suggestions? Thanks!

Nov 19 '05 #2

P: n/a
I don't think that'd work out too well in this case as the first page
(or control view, really) displays a form that prompts the user for
input parameters (i.e., "Select a year", etc.). After postback and
validation, I'd like to use a second control to create a user-specific
report based on the input parameters.

I don't know...maybe I need to rethink the site architecture.

Nov 19 '05 #3

P: n/a
sam
I'd check the span tag or whatever html is created for the validators
and make sure their controltovalidate ID values match the textbox ID
values. If you are adding controls too late or and setting IDs on them
manually it could screw this up.

Bascially you can debug the validation javascript yourself and see
where its stopping. Its not that hard. Put a breakpoint in
Page_ClientValidate (in WebUIValidation.js in c:\Inetpub\...) and
follow it urself. Also make sure that the call to Page_ClientValidatie
is being executed in the submit button onclick handler or wherever it
is in the html page.

Sorry I don't have exact details but its kindof late :). You can debug
this yourself i've done it many times.

-Sam Robertson

Nov 19 '05 #4

P: n/a
I'll give it a shot. Thanks for the info!

Nov 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.