Change the RegularExpressionValidator's ValidationExpression at cl

Discussion in 'ASP .Net Web Controls' started by Andy Eshtry, Jun 29, 2004.

  1. Andy Eshtry

    Andy Eshtry Guest

    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>
    Andy Eshtry, Jun 29, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?T2xpdmVyIFNjaHVsemU=?=

    ValidationExpression Syntax

    =?Utf-8?B?T2xpdmVyIFNjaHVsemU=?=, May 12, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    1,194
    =?Utf-8?B?T2xpdmVyIFNjaHVsemU=?=
    May 12, 2004
  2. =?Utf-8?B?SklNLkgu?=

    ValidationExpression

    =?Utf-8?B?SklNLkgu?=, Nov 17, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    8,204
    Peter Blum
    Nov 18, 2004
  3. TD
    Replies:
    3
    Views:
    8,697
  4. Morten71
    Replies:
    0
    Views:
    610
    Morten71
    Apr 2, 2007
  5. J055
    Replies:
    2
    Views:
    3,209
Loading...

Share This Page