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

RadWindow Popup closes automatically a second after opening

4 Answers 175 Views
Window
This is a migrated thread and some comments may be shown as answers.
Josh
Top achievements
Rank 1
Josh asked on 03 Aug 2012, 08:41 PM
I am trying to display a page in a RadWindow however the RadWindow closes by its self after about a second of loading the new window. I was hoping someone could look at my code and see if they notice anything wrong. I am new to Telerik so sorry if something seems strange.

<telerik:RadScriptBlock runat="server" ID="RadScriptBlock1">
    <script type="text/javascript">
        function openWindow() {      
            var window = $find('<%= crWindow.ClientID %>');
            alert("open");
            window.show();
        }
        function onWindowClosed(sender, args) {
            var ajaxManager = $find('<%= RadAjaxManager.GetCurrent(Page).ClientID %>');
            ajaxManager.ajaxRequest('crWindow');
            alert("close");
        }
    </script>
</telerik:RadScriptBlock>
<telerik:RadWindowManager runat="server" ID="crWindowManager">
    <Windows>
        <telerik:RadWindow runat="server" ID="crWindow" Title="test"
            Behaviors="Close,Resize,Move,Maximize" OnClientClose="onWindowClosed" VisibleOnPageLoad="False"
            VisibleStatusbar="False" Modal="true" Width="480px" Height="390px" KeepInScreenBounds="true" ShowContentDuringLoad="true"/>
    </Windows>
</telerik:RadWindowManager>
 
 <asp:Table ID="tableMasterMCA" runat="server">
                <asp:TableRow>
                    <asp:TableCell>
                        <asp:LinkButton ID="lnkCR" runat="server">Test</asp:LinkButton>
                    </asp:TableCell>
                </asp:TableRow>
</asp:Table>
I want the window to pop up when the link button is clicked so I also applied some c# code to the link button.

protected void Page_Load(object sender, EventArgs e)
        {
            lnkCR.Attributes.Add("onclick", "return openWindow()");
            crWindow.NavigateUrl = "~/Pages/CRForm.aspx";
        }

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 07 Aug 2012, 04:57 AM
Hi Josh,

The Radwindow is closing due to the postback generated by the Link Button. Please modify your code as follows to achieve your scenario.

Javascript:
<script type="text/javascript">
 function openWindow()
 {
  var window = $find('<%= crWindow.ClientID %>');
  alert("open");
  window.show();
  return false;
 }
</script>

Thanks,
Princy.
0
Peter
Top achievements
Rank 1
answered on 07 Dec 2012, 02:21 AM
I don't understand this behaviour: if I use a RadWindow with a simple anchor tag (onclick) the RadWindow stays open. If I use a RadButton, the window disappears. Why?

<telerik:GridTemplateColumn HeaderText="Legacy">                                       
                                        <ItemTemplate>                                           
                                            <telerik:RadButton runat="server" OnClientClicked="openLegacyPopUp">
                                                <Icon  PrimaryIconCssClass="rbOpen" />
                                            </telerik:RadButton>
                                        </ItemTemplate>
                                    </telerik:GridTemplateColumn>

0
Marin Bratanov
Telerik team
answered on 07 Dec 2012, 02:23 PM
Hello Peter,

The RadButton performs a postback by default, so you need to prevent it. You can do this by setting its AutoPostBack property to false. The anchor does not postback when clicked (by default).

On a side note regarding Princy's example - I would advise against using window as a JavaScript variable name because it is a reserved word - the window variable is the default window object the browser offers.


Kind regards,
Marin Bratanov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Arun
Top achievements
Rank 1
answered on 15 Jun 2017, 10:06 AM
is there any other option to prevent radwindow from being close automatically. You have used "return false" for that but I cant use that because a have OnClientClick and OnClick bothin my control it dosent execute OnClick event if I return false on OnClientClick
Tags
Window
Asked by
Josh
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Peter
Top achievements
Rank 1
Marin Bratanov
Telerik team
Arun
Top achievements
Rank 1
Share this question
or