Velocity Reviews

Velocity Reviews (
-   ASP .Net Web Controls (
-   -   Change the RegularExpressionValidator's ValidationExpression at cl (

Andy Eshtry 06-29-2004 10:17 PM

Change the RegularExpressionValidator's ValidationExpression at cl
I have a radio button list, a textbox representing SIN or EIN based on my radio button list selection so I put 2 regularexpressionvalidator to evaluate the value of textbox.

EIN must be (for simplicity) with this format (2 digits) like 12 (ValidationExpression="\d{3}-\d{2}")

and SIN must be (for simplicity) with this format (3digits-2digits) like 123-45 (ValidationExpression="\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.


Andy Eshterayeh

This is the ASPX.CS file

private void RadioButtonList1_SelectedIndexChanged(object sender, System.EventArgs e)


if(RadioButtonList1.SelectedValue.Equals("1")) //THIS IS EIN


ExpSSN.Enabled = false;

ExpSSN.Visible = false;

ExpEIN.Enabled = true;

ExpEIN.Visible = true;


if(RadioButtonList1.SelectedValue.Equals("2")) //THIS IS SSN


ExpEIN.Enabled = false;

ExpEIN.Visible = false;

ExpSSN.Enabled = true;

ExpSSN.Visible = true;



private void Button1_Click(object sender, System.EventArgs e)




This is the ASPX file

<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:RadioButtonList id="RadioButtonList1" style="Z-INDEX: 101; LEFT: 264px; POSITION: absolute; TOP: 192px"
runat="server" AutoPostBack="True" RepeatDirection="Horizontal" Width="376px">
<asp:ListItem Value="1">EIN (12)</asp:ListItem>
<asp:ListItem Value="2">SSN(123-45)</asp:ListItem>
<asp:validationsummary id="valfrmCustomerInfo" style="Z-INDEX: 107; LEFT: 352px; POSITION: absolute; TOP: 96px"
Runat="server" DisplayMode="BulletList" ForeColor="#ff0066"></asp:validationsummary>
<asp:requiredfieldvalidator id="ReqSSNEINRbtn" style="Z-INDEX: 106; LEFT: 192px; POSITION: absolute; TOP: 256px"
runat="server" ControlToValidate="RadioButtonList1" Display="None" ErrorMessage="Please select SSN or EIN Number "></asp:requiredfieldvalidator>
<asp:regularexpressionvalidator id="ExpSSN" style="Z-INDEX: 104; LEFT: 200px; POSITION: absolute; TOP: 328px" ControlToValidate="TextBox1"
Display="None" ErrorMessage="Please fill in a valid SSN Number" Enabled="False" ValidationExpression="\d{3}-\d{2}"
Visible="False" Runat="server">Please fill in a valid SSN Number</asp:regularexpressionvalidator>
<asp:Button id="Button1" style="Z-INDEX: 102; LEFT: 440px; POSITION: absolute; TOP: 376px" runat="server"
<asp:TextBox id="TextBox1" style="Z-INDEX: 103; LEFT: 376px; POSITION: absolute; TOP: 256px"
<asp:regularexpressionvalidator id="ExpEIN" style="Z-INDEX: 105; LEFT: 192px; POSITION: absolute; TOP: 296px" runat="server"
ControlToValidate="TextBox1" Display="None" ErrorMessage="Please enter a valid EIN Number" Enabled="False" ValidationExpression="\d{2}"
Visible="False">Please enter a valid EIN Number</asp:regularexpressionvalidator>

All times are GMT. The time now is 11:49 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.