I have a radio button list, a textbox representing SIN or EIN based on my radio button list selection so I put 2 regularexpressi onvalidator to evaluate the value of textbox.
EIN must be (for simplicity) with this format (2 digits) like 12 (ValidationExpr ession="\d{3}-\d{2}")
and SIN must be (for simplicity) with this format (3digits-2digits) like 123-45 (ValidationExpr ession="\d{3}-\d{2}")
It works well. The problem is: When I change the redio buttons selection, I do not want page to be refreshed. What is the right way?
I have used Microsoft validation controls in all pages so I want to generate the same format error message if I need to bypass the validations controls.
I put all the aspx.cs and asp code at the end of this email.
Please help. Thanks for your help.
Regards
Andy Eshterayeh
This is the ASPX.CS file
private void RadioButtonList 1_SelectedIndex Changed(object sender, System.EventArg s e)
{
if(RadioButtonL ist1.SelectedVa lue.Equals("1") ) //THIS IS EIN
{
ExpSSN.Enabled = false;
ExpSSN.Visible = false;
ExpEIN.Enabled = true;
ExpEIN.Visible = true;
}
if(RadioButtonL ist1.SelectedVa lue.Equals("2") ) //THIS IS SSN
{
ExpEIN.Enabled = false;
ExpEIN.Visible = false;
ExpSSN.Enabled = true;
ExpSSN.Visible = true;
}
}
private void Button1_Click(o bject sender, System.EventArg s e)
{
Response.Redire ct("rblist.aspx ");
}
This is the ASPX file
<body MS_POSITIONING= "GridLayout ">
<form id="Form1" method="post" runat="server">
<asp:RadioButto nList id="RadioButton List1" style="Z-INDEX: 101; LEFT: 264px; POSITION: absolute; TOP: 192px"
runat="server" AutoPostBack="T rue" RepeatDirection ="Horizontal " Width="376px">
<asp:ListItem Value="1">EIN (12)</asp:ListItem>
<asp:ListItem Value="2">SSN(1 23-45)</asp:ListItem>
</asp:RadioButton List>
<asp:validation summary id="valfrmCusto merInfo" style="Z-INDEX: 107; LEFT: 352px; POSITION: absolute; TOP: 96px"
Runat="server" DisplayMode="Bu lletList" ForeColor="#ff0 066"></asp:validations ummary>
<asp:requiredfi eldvalidator id="ReqSSNEINRb tn" style="Z-INDEX: 106; LEFT: 192px; POSITION: absolute; TOP: 256px"
runat="server" ControlToValida te="RadioButton List1" Display="None" ErrorMessage="P lease select SSN or EIN Number "></asp:requiredfie ldvalidator>
<asp:regularexp ressionvalidato r id="ExpSSN" style="Z-INDEX: 104; LEFT: 200px; POSITION: absolute; TOP: 328px" ControlToValida te="TextBox1"
Display="None" ErrorMessage="P lease fill in a valid SSN Number" Enabled="False" ValidationExpre ssion="\d{3}-\d{2}"
Visible="False" Runat="server"> Please fill in a valid SSN Number</asp:regularexpr essionvalidator >
<asp:Button id="Button1" style="Z-INDEX: 102; LEFT: 440px; POSITION: absolute; TOP: 376px" runat="server"
Text="Button"></asp:Button>
<asp:TextBox id="TextBox1" style="Z-INDEX: 103; LEFT: 376px; POSITION: absolute; TOP: 256px"
runat="server"> </asp:TextBox>
<asp:regularexp ressionvalidato r id="ExpEIN" style="Z-INDEX: 105; LEFT: 192px; POSITION: absolute; TOP: 296px" runat="server"
ControlToValida te="TextBox1" Display="None" ErrorMessage="P lease enter a valid EIN Number" Enabled="False" ValidationExpre ssion="\d{2}"
Visible="False" >Please enter a valid EIN Number</asp:regularexpr essionvalidator >
</form>
</body>