How to fire radwindow OnTextChanged event

4 posts, 0 answers
  1. Dorababu
    Dorababu avatar
    95 posts
    Member since:
    May 2012

    Posted 19 Jun 2012 Link to this post

    Hi all I am having my textbox designed as follows

    <telerik:RadMaskedTextBox Mask="###-##-####" runat="server" ID="txtSSN" Width="200px" AutoPostBack="true" OnTextChanged="ssnchanged">
            </telerik:RadMaskedTextBox>

    On my server side code I code as follows

    protected void ssnchanged(object sender, EventArgs e)
       {
           if (txtSSN.Text.Length != 9)
           {
              RadWindowManager1.VisibleOnPageLoad = true;
               string scriptstring = "radalert('You must save Employee Information to proceed further..', 250, 80,'Information');";
               ScriptManager.RegisterStartupScript(this, this.GetType(), "radalert", scriptstring, true);
           }
       }

    But unable to load the Window can some one help me..
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 19 Jun 2012 Link to this post

    Hi,

    Here is the sample code that works for me as expected. Please make sure that The RadTextBox is inside the UpdatePanel.

    ASPX:
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server">
    </telerik:RadWindowManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server"
      <ContentTemplate>
        <telerik:RadMaskedTextBox Mask="###-##-####" runat="server" ID="txtSSN" Width="200px" AutoPostBack="true" ontextchanged="txtSSN_TextChanged" >
        </telerik:RadMaskedTextBox>
      </ContentTemplate>
    </asp:UpdatePanel>

    C#:
    protected void txtSSN_TextChanged(object sender, EventArgs e)
        {
            if (txtSSN.Text.Length != 9)
            {
                RadWindowManager1.VisibleOnPageLoad = true;
                string scriptstring = "radalert('You must save Employee Information to proceed further..', 250, 80,'Information');";
                ScriptManager.RegisterStartupScript(this, this.GetType(), "radalert", scriptstring, true);
            }
        }

    Thanks,
    Shinu.

  3. Dorababu
    Dorababu avatar
    95 posts
    Member since:
    May 2012

    Posted 19 Jun 2012 Link to this post

    Hi thanks for the code but validation is not firing when I have validations as follows
    <asp:UpdatePanel ID="up" runat="server">
                <ContentTemplate>
                    <asp:Label runat="server" ID="lblSSN" CssClass="label1" AssociatedControlID="txtSSN"
                        Width="150px">Social Security Number</asp:Label>
                    <telerik:RadMaskedTextBox Mask="###-##-####" runat="server" ID="txtSSN" Width="200px"
                        AutoPostBack="true" OnTextChanged="ssnchanged" >
                    </telerik:RadMaskedTextBox>
                      
                    <asp:RequiredFieldValidator Display="Dynamic"
                        ID="mskdrqrdSSN" runat="server" ErrorMessage="Please, enter SSN number." ForeColor="Red"
                        ControlToValidate="txtSSN">
                    </asp:RequiredFieldValidator>
                    <asp:RegularExpressionValidator Display="Dynamic" ID="mskdregvdSSN" runat="server"
                        ErrorMessage="Format is ###-##-####" ControlToValidate="txtSSN"
                        ForeColor="Red" ValidationExpression="^\d{3}-\d{2}-\d{4}$" />
                </ContentTemplate>
            </asp:UpdatePanel>
  4. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 19 Jun 2012 Link to this post

    Hi Dorababu,

    Here is the sample code that I tried based on your scenario and it is working as expected.

    ASPX:
    <asp:UpdatePanel ID="UpdatePanel1" runat="server"
       <ContentTemplate>
         <asp:Label runat="server" ID="lblSSN" CssClass="label1" AssociatedControlID="txtSSN"  Width="150px">Social Security Number</asp:Label>
         <telerik:RadMaskedTextBox Mask="###-##-####" runat="server" ID="txtSSN"  Width="200px" AutoPostBack="true" ontextchanged="txtSSN_TextChanged" >
         </telerik:RadMaskedTextBox>
         <asp:RequiredFieldValidator Display="Dynamic" ID="mskdrqrdSSN" runat="server" ErrorMessage="Please, enter SSN number." ForeColor="Red"  ControlToValidate="txtSSN">
         </asp:RequiredFieldValidator>
         <asp:RegularExpressionValidator Display="Dynamic" ID="mskdregvdSSN" runat="server" ErrorMessage="Format is ###-##-####" ControlToValidate="txtSSN"  ForeColor="Red" ValidationExpression="^\d{3}-\d{2}-\d{4}$" />
       </ContentTemplate>
    </asp:UpdatePanel>

    C#:
    protected void txtSSN_TextChanged(object sender, EventArgs e)
        {
            if (txtSSN.Text.Length != 9)
            {
                RadWindowManager1.VisibleOnPageLoad = true;
                string scriptstring = "radalert('You must save Employee Information to proceed further..', 250, 80,'Information');";
                ScriptManager.RegisterStartupScript(this, this.GetType(), "radalert", scriptstring, true);
            }
        }

    Please see the screenshot.

    Thanks,
    Shinu.
Back to Top