i have a register form & in that form i have a 2 textboxes
for entering name&age.my doubt is that how can i provide
error message like "invalid entry" when user enter a
invalid name/age(eg:user enter name as #%%%##daff,and age
as 1000.)in that textboxes.I want code.

Answers were Sorted based on User's Feedback



i have a register form & in that form i have a 2 textboxes for entering name&age.my doubt ..

Answer / saravanakumar

We can use RegularExpressionValidator to validate the textbox content.

Is This Answer Correct ?    2 Yes 0 No

i have a register form & in that form i have a 2 textboxes for entering name&age.my doubt ..

Answer / rajeev kumar varshney

char[] SpecialChars = "#%".ToCharArray();
string text=TextBox1.Text;


int indexOf = text.IndexOfAny(SpecialChars);

if(indexOf != -1)
{
Page.ClientScript.RegisterStartupScript("this.getType(),"a","<script>alert('Please do not enter % or # in name');</script>");

}

Is This Answer Correct ?    1 Yes 0 No

i have a register form & in that form i have a 2 textboxes for entering name&age.my doubt ..

Answer / satheshkumar

name textbox should follow the reqularexpersion valitator and age textbox should follow the range validator

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More ASP.NET Interview Questions

Where you store Connection string in "Web.Config" file in ASP.NET?

0 Answers   Sans Pareil IT Services,


How do you trap errors in ASP and how do you invoke a component in ASP ?

1 Answers   Cognizant,


Can you clarified A Web service can only be written in .NET or not?

0 Answers   Siebel,


What is the difference between application object and session object?

4 Answers   IBS,


How much is the pay-for-use service if I chose not to use microsoft-sponsored advertising?

0 Answers  


What is the difference between typeof() vs gettype()?

0 Answers  


What is the difference between rest and restful?

0 Answers  


Differnce between Control an View State

1 Answers   Proteans,


What is the biggest disadvantage of “Other Return Types” in Web API?

0 Answers  


What is the difference between Server.Transfer and Response.Redirect?

5 Answers  


How can we call webservices in Banking Applications? and where we are using it?

0 Answers   FCG,


What is viewstate parameter?

0 Answers  


Categories