Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Change the RegularExpressionValidator's ValidationExpression at cl

Reply
Thread Tools

Change the RegularExpressionValidator's ValidationExpression at cl

 
 
Andy Eshtry
Guest
Posts: n/a
 
      06-29-2004
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.

Regards

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)

{

Response.Redirect("rblist.aspx");

}

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:RadioButtonList>
<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"
Text="Button"></asp:Button>
<asp:TextBox id="TextBox1" style="Z-INDEX: 103; LEFT: 376px; POSITION: absolute; TOP: 256px"
runat="server"></asp:TextBox>
<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>
</form>
</body>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ValidationExpression that simulates the MaxLength property Nathan Sokalski ASP .Net 2 01-03-2007 07:30 AM
ValidationExpression Error skardian@gmail.com ASP .Net 3 11-17-2006 08:55 PM
ValidationExpression for a single number TD ASP .Net 3 11-30-2005 11:32 AM
ValidationExpression =?Utf-8?B?SklNLkgu?= ASP .Net 4 11-18-2004 05:45 PM
ValidationExpression Syntax =?Utf-8?B?T2xpdmVyIFNjaHVsemU=?= ASP .Net 0 05-12-2004 02:06 PM



Advertisments