943,954 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 20873
  • ASP.NET RSS
May 20th, 2005
0

validating a textbox without using validation control

Expand Post »
I have 3 textboxes in my webform.I want my user to enter valid entries into them. If user leaves any textbox empty.I want Give him an alert to him (like a msgbox in vb.net).I'm using textboxes in asp.net(web server controls).I dont want to use the validation controls as they wont give a pop up message.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ramareddy_dotne is offline Offline
15 posts
since May 2005
May 22nd, 2005
0

Re: validating a textbox without using validation control

in the submit button do something like

if (txtField1.Text = "")
{
msgbox = "Sorry please enter something in txtFeild1";
}

Try something like that.
Reputation Points: 12
Solved Threads: 0
Light Poster
percent20 is offline Offline
33 posts
since Jan 2005
Jun 15th, 2010
0
Re: validating a textbox without using validation control
percent20's coding is not working in the asp.net server.This is the correct code and WHICH IS WORKING ONLY WITH c#Make sure this lable1 is disabled the visible properties in the properties
ASP.NET Syntax (Toggle Plain Text)
  1. if (txtField1.Text =="")
  2. { label1.Visible = true;
  3. }
Last edited by kasun.u; Jun 15th, 2010 at 5:26 pm.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
kasun.u is offline Offline
2 posts
since Jun 2010
Jun 16th, 2010
0
Re: validating a textbox without using validation control
I have 3 textboxes in my webform.I want my user to enter valid entries into them. If user leaves any textbox empty.I want Give him an alert to him (like a msgbox in vb.net).I'm using textboxes in asp.net(web server controls).I dont want to use the validation controls as they wont give a pop up message.
Hi Rama
You have mentioned a specific reason "they wont give a pop up message" is this the reason why you are not using validation controls?

Validation Control are performed on client side n therefore good user experience, on the other hand you have server side validation which you can write a peiece of code to validate controls . you just have set display="None", which gives you pop up message.

client validation control
ASP.NET Syntax (Toggle Plain Text)
  1. <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Qty") %>' Width="50px" MaxLength="3" AutoPostBack="True" OnTextChanged="TextBox1_TextChanged"></asp:TextBox>
  2. <asp:RequiredFieldValidator ID="RequiredFieldValidator1"
  3. runat="server"
  4. ErrorMessage="You must enter Qty"
  5. ValidationGroup="v1"
  6. ControlToValidate="TextBox1" Display="None" SetFocusOnError="true" >
  7.  
  8. <asp:ValidationSummary ID="ValidationSummary1" runat="server" ShowSummary="false" ShowMessageBox="true" ValidationGroup="v1" />


Mark as solved if it helps you!!!
Reputation Points: 12
Solved Threads: 38
Junior Poster
reach_yousuf is offline Offline
194 posts
since Sep 2007
Jun 16th, 2010
0
Re: validating a textbox without using validation control
use javascript and Regx...
one and the same thing..
Reputation Points: 28
Solved Threads: 106
Banned
dnanetwork is offline Offline
633 posts
since May 2008
Jan 27th, 2011
0
Re: validating a textbox without using validation control
ASP.NET Syntax (Toggle Plain Text)
  1. <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Qty") %>' Width="50px" MaxLength="3" AutoPostBack="True" OnTextChanged="TextBox1_TextChanged"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="You must enter Qty" ValidationGroup="v1" ControlToValidate="TextBox1" Display="None" SetFocusOnError="true" > <asp:ValidationSummary ID="ValidationSummary1" runat="server" ShowSummary="false" ShowMessageBox="true" ValidationGroup="v1" /><asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Qty") %>' Width="50px" MaxLength="3" AutoPostBack="True" OnTextChanged="TextBox1_TextChanged"></asp:TextBox>
  2. <asp:RequiredFieldValidator ID="RequiredFieldValidator1"
  3. runat="server"
  4. ErrorMessage="You must enter Qty"
  5. ValidationGroup="v1"
  6. ControlToValidate="TextBox1" Display="None" SetFocusOnError="true" >
  7.  
  8. <asp:ValidationSummary ID="ValidationSummary1" runat="server" ShowSummary="false" ShowMessageBox="true" ValidationGroup="v1" />
Last edited by Ezzaral; Jan 27th, 2011 at 1:13 pm. Reason: Added code tags. Please use them to format any code that you post.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
shahnawaz khan is offline Offline
1 posts
since Jan 2011

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: Common Controls Reload
Next Thread in ASP.NET Forum Timeline: Multiple version of assembly





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC