• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 530
  • Last Modified:

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
0
etalexit
Asked:
etalexit
  • 2
  • 2
  • 2
  • +3
1 Solution
 
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
  • 2
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now