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

What you mean by partial Class in asp.net 2.0?

3 Answers   TCS,


difference between Trace and Debug ?

2 Answers   Accenture, HCL, Patni,


What is custom control. What is the difference between custom control and user control?

2 Answers   Microsoft,


Write a code for sending an email from asp.net application.

0 Answers  


How To Send Value one page to Another Page On MasterMenu Click ? please Tell Me!

3 Answers   Accenture,






Explain what benefit does your code receive if you decorate it with attributes demanding specific security permissions?

0 Answers  


Is global asax mandatory?

0 Answers  


What is the default timeout for a cookie?

0 Answers  


What is a session in asp.net?

0 Answers  


Explain how is a property designated as read-only?

0 Answers  


What layout mode is the default when a new Web Form is created? a) GridBagLayout b) GridLayout c) FlowLayout d) FormLayout

2 Answers   Syntax Softtech,


What are the authentication types in asp.net?

0 Answers  


Categories