clear textboxes value's after radwindow close

5 posts, 1 answers
  1. Somy
    Somy avatar
    6 posts
    Member since:
    May 2013

    Posted 03 May 2013 Link to this post

    Hi
    I have a radwindow with some textboxes. user can edit thextboxes values. when the user close the window, I want to clear all textboxes values.
    how can I do that.
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 03 May 2013 Link to this post

    Hi Somy,

    You can attach the OnClientClose client event of the RadWindow and the following JS code to clear the textbox values once the Radwindow is closed. Please have a look at the following sample code.

    ASPX:
    <telerik:RadWindow ID="RadWindow1" runat="server" VisibleOnPageLoad="true" OnClientClose="OnClientClose">
        <ContentTemplate>
            <br />
            <telerik:RadTextBox ID="RadTextBox1" runat="server" Text="Text1">
            </telerik:RadTextBox>
            <br /><br />
            <telerik:RadTextBox ID="RadTextBox2" runat="server" Text="Text2">
            </telerik:RadTextBox>
        </ContentTemplate>
    </telerik:RadWindow>

    JavaScript:
    <script type="text/javascript">
        function OnClientClose() {
            var TextBox1 = $find('<%=RadTextBox1.ClientID %>');
            var TextBox2 = $find('<%=RadTextBox2.ClientID %>');
            TextBox1.clear();
            TextBox2.clear();
        }
    </script>

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Somy
    Somy avatar
    6 posts
    Member since:
    May 2013

    Posted 03 May 2013 Link to this post

    my aspx code is:
    <telerik:RadWindow ID="RadWindow1" runat="server" Width="800px" Height="600px">
             
            <ContentTemplate>
            <asp:TextBox ID="TxtTitle" runat="server"></asp:TextBox>
            <br />
            <asp:TextBox ID="TxtDetail" runat="server" style="resize:none"></asp:TextBox>
            <br />
            <asp:TextBox ID="TxtDate" runat="server" style="resize:none"></asp:TextBox>
            <br />
             
     
            <telerik:RadEditor ID="RadEditor1" runat="server"  ImageManager-ViewPaths="~/Images"
        ImageManager-UploadPaths="~/Images"
        ImageManager-DeletePaths="~/Images">
            </telerik:RadEditor>
     
            <br />
     
     
            <asp:FileUpload ID="FileUpload1" runat="server" />
            <br />
            <asp:CheckBox ID="ChkActive" runat="server" />
            <br />
            <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="ذخیره" />
            <br />
     
            </ContentTemplate>
            </telerik:RadWindow>
    and I use that code like the below but when one time close and reopen the window textboxes are filled and not empty.
    function OnClientClose() {
                var TextBox1 = $find('<%=RadTextBox1.ClientID %>');
                var TextBox2 = $find('<%=RadTextBox2.ClientID %>');
                TextBox1.clear();
                TextBox2.clear();
    }
  5. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 05 May 2013 Link to this post

    Hi Somy,

    I have checked you code and found that you didn't attach the OnClientClose event to the RadWindow. Also the RadTextBox id specified in your JavaScript code differ from the one you have given in the mark-up. Please check the following code.

    ASPX:
    <telerik:RadWindow ID="RadWindow1" runat="server" VisibleOnPageLoad="true" Width="800px"
        Height="600px" OnClientClose="OnClientClose">
        <ContentTemplate>
            <asp:TextBox ID="TxtTitle" runat="server"></asp:TextBox>
            <br />
            <asp:TextBox ID="TxtDetail" runat="server" Style="resize: none"></asp:TextBox>
            <br />
            <asp:TextBox ID="TxtDate" runat="server" Style="resize: none"></asp:TextBox>
            <br />
            <telerik:RadEditor ID="RadEditor1" runat="server" ImageManager-ViewPaths="~/Images"
                ImageManager-UploadPaths="~/Images" ImageManager-DeletePaths="~/Images">
            </telerik:RadEditor>
            <br />
            <asp:FileUpload ID="FileUpload1" runat="server" />
            <br />
            <asp:CheckBox ID="ChkActive" runat="server" />
            <br />
            <asp:Button ID="Button1" runat="server" Text="ذخیره" />
            <br />
        </ContentTemplate>
    </telerik:RadWindow>

    JavaScript:
    <script type="text/javascript">
        function OnClientClose() {
            var TxtTitle = $find('<%=TxtTitle.ClientID %>');
            var TxtDetail = $find('<%=TxtDetail.ClientID %>');
            TxtTitle.clear();
            TxtDetail.clear();
        }
    </script>

    Thanks,
    Princy.
  6. Somy
    Somy avatar
    6 posts
    Member since:
    May 2013

    Posted 06 May 2013 Link to this post

    Thank you for helping.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017