Hi all.I have some text boxes in my aspx page and some text boxes will axxpet only string values and some other will accpet only integers or double values.
Is there any validation control to validate a textbox such that it will accpt only integeres or only string values?
How can I do this?
Thank You for reading this topic.
8 Replies - 800 Views - Last Post: 19 January 2012 - 12:54 PM
Topic Sponsor:
#1
Using validator server controls to validate some textbox controls
Posted 03 October 2011 - 11:35 AM
Replies To: Using validator server controls to validate some textbox controls
#2
Re: Using validator server controls to validate some textbox controls
Posted 04 October 2011 - 04:10 AM
I don't know of a validator but if you use the AjaxControlToolkit there is a FilteredTextBoxExtender control that allows you to limit the input to specific values
FilteredTextBoxExtender
FilteredTextBoxExtender
This post has been edited by Nakor: 04 October 2011 - 04:11 AM
#3
Re: Using validator server controls to validate some textbox controls
Posted 04 October 2011 - 07:39 AM
Thank You for your answer...but as i was reading in some forums about thit i found that in RegularExpressionValidator in the validationExpression propertie I can put this : "^[A-Za-z]{1,}$" than it will prevent user to put number in that field .It also prevent users to put spaces(it useful for fields in wich user will write for example name or surname or something like that).
I will llok how to use ajax toolkit because I`m not using it yet..but if you have anything useful for me to learn how to use Ajax Toolkit it will be good for me to learn also about that.
Thank You and have a nice day!
I will llok how to use ajax toolkit because I`m not using it yet..but if you have anything useful for me to learn how to use Ajax Toolkit it will be good for me to learn also about that.
Thank You and have a nice day!
#4
Re: Using validator server controls to validate some textbox controls
Posted 04 October 2011 - 08:41 AM
Nakor, on 04 October 2011 - 05:10 AM, said:
I don't know of a validator but if you use the AjaxControlToolkit there is a FilteredTextBoxExtender control that allows you to limit the input to specific values
FilteredTextBoxExtender
FilteredTextBoxExtender
Thank You very much...I just start using Ajax toolkit and i also used FilterTextBox and it is very good.It prevents users to write numbers or uppercaseletters or lowercaseletters or combine of those properties.
Thanks it is very good for my web appliation.
#5
Re: Using validator server controls to validate some textbox controls
Posted 04 October 2011 - 11:54 AM
Hmm I wouldn't have suggested an Ajax extender when there are tons of Validating ASP.NET Server Controls available right in the .NET Framework.
-Frinny
-Frinny
#6
Re: Using validator server controls to validate some textbox controls
Posted 04 October 2011 - 12:46 PM
well I have another question about validators.I am a starter in ASP.NET and in programming in general and this is my firts time working with validators.As I can see all validations happens in client side and if there is any error the page is not doing a postback...so is ti nessesary to make validation also in server side .I mean do I Have to write code in code behind in server side?
#7
Re: Using validator server controls to validate some textbox controls
Posted 04 October 2011 - 01:29 PM
You should always do server-side validation.
The validators use Javascript to validate the data before sending it to the server. They let the user correct everything so that there are less round-trips involved.
If the user is able to get around the Javascript validation (which is quite easy to do) in an attempt purposefully submit invalid data, you can check the Page.IsValid property in your server side to prevent any data processing that should not be done if the data is invalid. This will prevent any undesired outcome.
For example:
Honestly I recommend that you implement and test any custom sever-side validation first and then add Javascript to the page to supplement the validation process....
The validators use Javascript to validate the data before sending it to the server. They let the user correct everything so that there are less round-trips involved.
If the user is able to get around the Javascript validation (which is quite easy to do) in an attempt purposefully submit invalid data, you can check the Page.IsValid property in your server side to prevent any data processing that should not be done if the data is invalid. This will prevent any undesired outcome.
For example:
Protected Sub Buttonclick(ByVal sender As Object,ByVal e As EventArgs)
If (Page.IsValid) Then
errorLabel.Text = "Page is valid."
Else
errorLabel.Text = "Page is not valid!!"
End If
End Sub
Honestly I recommend that you implement and test any custom sever-side validation first and then add Javascript to the page to supplement the validation process....
This post has been edited by Frinavale: 04 October 2011 - 01:30 PM
#8
Re: Using validator server controls to validate some textbox controls
Posted 04 October 2011 - 09:48 PM
I just went with the extender because the question didn't really involve validation but was about limiting user input. Of course you should always validate the input on the server to make sure the data is in the correct form.
#9
Re: Using validator server controls to validate some textbox controls
Posted 19 January 2012 - 12:54 PM
Thank you for the sensible critique on www.dreamincode.net . Me & my neighbor were just preparing to do some research about this. We got a grab a book from our local library but I think I learned more from this post. I am very glad to see such great information being shared freely out there.
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote





|