RadButton can open a RadWindow but auto close

2 posts, 0 answers
  1. juan
    juan avatar
    2 posts
    Member since:
    Oct 2010

    Posted 17 Aug 2011 Link to this post

    Hi all,
    I have used aspButton to open RadWindow , it's work success
    but i used radButton to open RadWindow, it's can open but immediately auto close
    Please give me solution on this problem.why rad window auto close with rad button.
    TKS~
    <head
        <title></title
        
        <script type="text/javascript"
        
            function openWin() { 
        
                window.radopen("Default5.aspx", "UserListDialog"); 
                return false; 
            
        
        </script
        
    </head
    <body
        <form id="form1" runat="server"
        <telerik:RadScriptManager ID="sc1" runat="server"
        </telerik:RadScriptManager
            
        <telerik:RadWindowManager ID="RadWindowManager1" runat="server"
            <Windows
                <telerik:RadWindow ID="UserListDialog" runat="server" Height="320px"
                    Width="550px" Left="150px" 
                    /> 
            </Windows
        </telerik:RadWindowManager
        <asp:Button ID="aspButton" runat="server" Text="aspButton" /> 
        <telerik:RadButton ID="radButton" runat="server" Text="radButton" /> 
        </form
    </body>

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 
           If Not IsPostBack Then
               Me.aspButton.Attributes.Add("onclick", "return openWin();return false;"
               Me.radButton.Attributes.Add("onclick", "return openWin();return false;"
           End If
       End Sub
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 18 Aug 2011 Link to this post

    Hello Juan,
    RadWindow disappears because you open it by using JavaScript by clicking on a server control that causes a postback. What happens is that when the clientclick event fires, the window opens but then postback occurs which reloads the whole page. To avoid that, you should cancel the postback.
    <head>
      <script type="text/javascript">
            function openWin()
            {
                window.radopen("Default5.aspx", "UserListDialog");
            }
        </script>
    </head>
    <body>
    <form id="form1" runat="server">
        <telerik:RadScriptManager ID="sc1" runat="server">
        </telerik:RadScriptManager>
        <telerik:RadWindowManager ID="RadWindowManager1" runat="server">
            <Windows>
                <telerik:RadWindow ID="UserListDialog" runat="server" Height="320px" Width="550px"
                    Left="150px" />
            </Windows>
        </telerik:RadWindowManager>
        <asp:Button ID="aspButton" runat="server" Text="aspButton" />
        <telerik:RadButton ID="radButton" runat="server" Text="radButton" OnClientClicking="openWin" AutoPostBack="false" />
    </form>

    Also take a look into the following help article.
    opening Windows.

    Thanks,
    Shinu.
Back to Top