This is a migrated thread and some comments may be shown as answers.

How to fire radwindow OnTextChanged event

3 Answers 65 Views
Window
This is a migrated thread and some comments may be shown as answers.
Dorababu
Top achievements
Rank 1
Dorababu asked on 19 Jun 2012, 01:35 PM
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..

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 19 Jun 2012, 02:54 PM
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.

0
Dorababu
Top achievements
Rank 1
answered on 19 Jun 2012, 03:03 PM
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>
0
Shinu
Top achievements
Rank 2
answered on 20 Jun 2012, 03:59 AM
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.
Tags
Window
Asked by
Dorababu
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Dorababu
Top achievements
Rank 1
Share this question
or