This is a discussion on Validation Function / Class within the .Net Development forums, part of the Programming & Scripting category; Originally Posted by jmurrayhead Code: <asp:TextBox ID="TextBox1" runat="server" /> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" Display="Dynamic" ErrorMessage="TextBox1 is required" Text="*" /> <asp:RegularExpressionValidator ...
| |||||||
|
#11
| ||||
| ||||
| Quote:
And, in the example I gave, you could change <asp: panel> control to ValidationSummary and all error messages for all validation controls would show here?
__________________ Join the folding team |
|
#13
| ||||
| ||||
| Quote:
![]() Quote:
![]() Quote:
__________________ jmurrayhead If you agree with me... click the icon! If my post solved your problem, click the button in the lower right-hand corner of the post.If you like it here...throw us a few bones to help support us. Join our Folding team: DeveloperBarn Folding |
|
#14
| ||||
| ||||
| Quote:
And each for other controls that you want to validate. Quote:
I think they use javascript to fire, so if the js is disables, then they might not fire and hence the need for server side validation.
__________________ Get the Mantra! |
|
#15
| ||||
| ||||
| Quote:
Code: Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSave.Click
If Page.IsValid Then
' Code to save the record here
End If
End Sub
|
| The Following User Says Thank You to jmurrayhead For This Useful Post: | ||
micky (November 16th, 2009) | ||
|
#16
| ||||
| ||||
| thats good to know J |
|
#17
| ||||
| ||||
| Would it be able to handle the scenario where you might have two submit controls where one submits the form in full and the other only checks a few of the textboxes? Say, for example, you have a form that has name, date of birth and address details and a button that prepopulates a series of address textboxes if the user just enters a postcode / zipcode. So, you want to validate the postcode, zipcode is valid when prepopulating the address, but you don't want to validate the name and date of birth fields until the full form is submitted. How would you handle this using validation controls? I presume if you used Page.IsValid in the GetAddress function, it would pick up the name and date of birth validations as well. |
|
#18
| ||||
| ||||
| Validation controls have a property called "ValidationGroup" where you would set the name (i.e. ValidationGroup="SaveRecord"). You would have to assign the ValidationGroup property of the individual buttons, using the same name as the form items they are to validate. |
| The Following User Says Thank You to jmurrayhead For This Useful Post: | ||
richyrich (November 16th, 2009) | ||
|
#19
| ||||
| ||||
| Just in case anyone comes across this thread for information, I had to change the validation expression to below:- Code: <asp:RegularExpressionValidator ID="revForename" runat="server" ControlToValidate="txtForename"
ErrorMessage="The forename you entered contains invalid characters" ValidationExpression="^[a-zA-Z ]+$"
Display="None" EnableClientScript="true" />
|
![]() |
|
| Bookmarks |
| Tags |
| controls, function, validation |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Email Class | jmurrayhead | .Net Code Samples | 2 | July 8th, 2009 07:49 AM |
| Button Class | richyrich | HTML & CSS Help | 18 | February 27th, 2009 12:32 PM |
| class name is ambiguous | richyrich | .Net Development | 11 | August 12th, 2008 11:11 AM |
| FTP Class Library? | Wolffy | .Net Development | 6 | May 30th, 2008 10:26 AM |
| Class library | Shem | .Net Development | 11 | May 22nd, 2008 07:01 AM |