Check textbox numericGSg s11yAsked Oct 30, 2015, 1:00 AM EDT4 answersShareLinkedInXCopy linkSavehow to check textbox values String or Numeric asp.net c#?
Check textbox numericGSg s11yAsked Oct 30, 2015, 1:00 AM EDT4 answersShareLinkedInXCopy linkSavehow to check textbox values String or Numeric asp.net c#?
RKRavi KumarRank #2,085 · 690 reputation11y agoPosted Oct 30, 2015, 1:28 AM EDT+1BashCopy id="RegularExpressionValidator1" ControlToValidate="TextBox1" ValidationExpression="\d+" Display="Static" EnableClientScript="true" ErrorMessage="Please enter numbers only" runat="server"/>+1
Ravi PatelRank #439 · 5.7K reputation11y agoPosted Oct 30, 2015, 2:31 AM EDT+1Hi, You can try this also private void Button1_Click(object sender, EventArgs e){ try { int.Parse(TXT_Number.Text); } catch { LabelError.Text = "You have not entered a number"; }} +1
SSenzeye96 reputation11y agoPosted Oct 30, 2015, 3:32 AM EDT+1http://dotnetdrizzles.blogspot.in/2015/10/check-textbox-value-isnumeric-or-string.html+1
Priyaranjan K SRank #45 · 32.5K reputation11y agoPosted Oct 30, 2015, 3:51 AM EDT+1Hi, You can check this in server side as : If you are looking for an integer value you could use int.TryParse:int result;if (int.TryParse("123", out result)){ Debug.WriteLine("Valid integer: " + result);}else{ Debug.WriteLine("Not a valid integer");}For checking a decimal number, replace int.TryParse with Decimal.TryParse You can also use Regular expression Validation as below : top: 283px" ValidationGroup="check">ErrorMessage="Please Enter Only Numbers" Style="z-index: 101; left: 424px; position: absolute;top: 285px" ValidationExpression="^\d+$" ValidationGroup="check"> Thanks,Priyan If you found this useful Please Accept this as Answer . +1Join to answer this questionEvery answer you publish earns 20 SHARP.Create free accountSign inKnow the answer?Answer a question in the forums and earn +20 SHARP for every answer.See unanswered questionsForumsTop experts01Arun PottiAnswers in the forums20answers02Tahir AnsariAnswers in the forums5answers03Kamlesh KumarAnswers in the forums5answers04Sam HobbsAnswers in the forums4answers05Željko PerićAnswers in the forums3answers?YouYour name goes here.Every answer: 20 SHARP.JoinFull leaderboard →2026DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Ravi KumarRank #2,085 · 690 reputationPosted Oct 30, 2015, 1:28 AM EDT
id="RegularExpressionValidator1" ControlToValidate="TextBox1" ValidationExpression="\d+" Display="Static" EnableClientScript="true" ErrorMessage="Please enter numbers only" runat="server"/>Ravi PatelRank #439 · 5.7K reputationPosted Oct 30, 2015, 2:31 AM EDT
Senzeye96 reputationPosted Oct 30, 2015, 3:32 AM EDT
Priyaranjan K SRank #45 · 32.5K reputationPosted Oct 30, 2015, 3:51 AM EDT
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts