ASP.net partial page validation

Dear experts,

I have designed an asp.net page to update user information.
The page is divided into sections
1) Update User Information
2) Update User password

In section 1, there are:
text boxes
validation controls( to verify entry)
save button
The onclick event of the save button triggers page validation to ensure correct entry

Section 2 is similar to section 1, there are
text boxes
validation controls( to verify entry)
update button
The onclick event of the upate button triggers the page validation to ensure correct entry


Is there an easy way to make the save button in section 1 to validate the controls in section 1 only ; and to make the update button in section 2 to validate controls in section 2 only?

Thanks for any help
etalexitAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mrwebdevCommented:
Does Section 1 & 2 have their own Form name,
if so it shouldn't be hard to set the validation to
each forms name upon updating.

Hope this helps!

0
etalexitAuthor Commented:
A page can only have one runat="server" form tag

I place the two sections in two panels, it still dosent work.

0
margantCommented:
hi,
etalaexit,
I had a similar problem and i ended up verifying the boxes manually, using
Len(tbxName.Text)>0 and Char.IsNumeric functions inside the Button's OnClick Functions. I printed out errors in the label that was sitting on top of the page, by adding error text to it.

There are plenty of validation functions available if you google for them.

Best of luck,
AM
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

davidlars99Commented:
looks like you might be taking a little detour, why don't you post your code?
0
davidlars99Commented:
looks like you might be taking a little detour, why don't you post your code?
0
smolamCommented:
Hi, there is one way that this can be done, and correct me if I am wrong but this is probably the only way you can do this with all the controls on the same form.  You can use the built in javascript function ValidatorEnable(validator, boolean) this is part of the ASP.Net validators javascript library that gets included in the page when you add validation controls.  What you would need to do is add and onclick attribute to each of the update buttons which will disable the validation controls, I would just pass it a function name and have 2 javascript functions that will disable the validators.  Like as follows:

'Add this to the <HEAD> section of your HTML.
<SCRIPT language="javascript">
function disableVal(b_disable){

'Disable one set of validators
ValidatorEnable(document.all("valControl1"), b_disable);
ValidatorEnable(document.all("valControl2"), b_disable);

'do the opposite to the other set
ValidatorEnable(document.all("valControl3"), !b_disable);
ValidatorEnable(document.all("valControl4"), !b_disable);
}
</SCRIPT>

Then on the buttons you would do something like this in the Page_Load
btnUpdate1.Attributes.Add("OnClick","disableVal(true);")

and for the other something like this
btnUpdate2.Attributes.Add("OnClick","disableVal(false);")

HTH, if you need any explanations let me know.
0
etalexitAuthor Commented:
After a long battle, I finally got the solution. It is pretty simple

1) set the EnableClientScript = false and visible = false for all the validation controls (both sets) in the properties window

on the click event of save button1:
2) set  visible = true for the first set of validation controls e.g. Val1.visible = true
3) call the validate method for the first set of validate controls  e.g. Val1.validate()
4) set visible = false for the second set of validation controls e.g. Val2.visible = false
5) exit sub if the validation controls are valid (first set only), e.g.
if val1.IsValid Then
    'set visible = false for the second set of validation controls
    exit sub
end if

on the click evnet of save button 2:
6) set  visible = true for the second set of validation controls e.g. Val2.visible = true
3) call the validate method for the second set of validate controls  e.g. Val2.validate()
4) set visible = false for the first set of validation controls e.g. Val1.visible = false
5) exit sub if the validation controls are valid (second set only), e.g.
if val2.IsValid Then
    'set visible = false for the second set of validation controls
    exit sub
end if
0
smolamCommented:
Yep a bit like what I was suggesting, well glad you found a solution!
0
moduloCommented:
PAQed with points refunded (500)

modulo
Community Support Moderator
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.