I have 1 text box - Textbox1
2 Radiobuttons - Rb1,Rb2.
my problem is
if i select Rb1- Textbox1 accept only numeric values.
Rb2 selected - Textbox2 accept alphanumeric values only
plz help me
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Manish Kumar ChoudharyPosted Jan 4, 2015, 11:24 PM
Hi AKSHAY HARSHA,
Use a CustomValidator that implements it's own regular expression logic based on a conditional operator. In other words:
public void someCustomValidator(object obj, ServerValidateEventArgs e)
{
}
For regular expression go through following article
http://www.c-sharpcorner.com/UploadFile/ee01e6/important-list-of-regular-expressions-and-its-uses/
RakeshPosted Jan 5, 2015, 9:40 AM
AKSHAY HARSHAPosted Jan 5, 2015, 6:55 AM
i have only 1 textbox with 2 radiobuttons..
your code is working while two texboxes with 2 radiobuttons.
plz understand my question and give reply
AKSHAY HARSHAPosted Jan 5, 2015, 6:53 AM
Could you plz explain with example.. i need it
RakeshPosted Jan 5, 2015, 12:25 AM
Rajagopalan R VPosted Jan 4, 2015, 11:32 PM
AKSHAY HARSHA.,
In Your aspx Page
<td>
<asp:TextBox ID="tbx1" runat="server" Visible="false">asp:TextBox>
<asp:TextBox ID="tbx2" runat="server" Visible="false">asp:TextBox>
<td>
<asp:RadioButtonList ID="radioButton1" runat="server" AutoPostBack="true"
OnSelectedIndexChanged=" radioButton1_SelectedIndexChanged">
asp:RadioButtonList>
td>
<td>
<asp:RadioButtonList ID="radioButton2" runat="server" AutoPostBack="true"
OnSelectedIndexChanged=" radioButton2_SelectedIndexChanged">
asp:RadioButtonList>
td>
In Your cs Page
protected void radioButton1_SelectedIndexChanged(object sender, EventArgs e)
{
tbx1.Visible=true;
tbx2.Visible=false;
}
protected void radioButton2_SelectedIndexChanged(object sender, EventArgs e)
{
tbx1.Visible=false;
tbx2.Visible=true;
}