Rad Window Opens Then Immediately Closes

6 posts, 1 answers
  1. Tracy
    Tracy avatar
    123 posts
    Member since:
    Nov 2010

    Posted 03 Jan 2011 Link to this post

    Hi,
     I have a grid with an image button that opens a rad window.  My problem is that the window opens and then about 3-4 seconds later automatically closes.

    I am setting the OnClick event of the image button (ibtPackageStatus) in Code Behind because I need to pass the javascript function a value (ImportExecutionId) from the grid row and have not been able to successfully retrieve the value using inline code. 

    I have tried many things to narrow down what is causing the problem but I can't find a solution:

    1.  As you can see from my code below I changed the javascript function to open google rather than my page to see if the problem was being caused by the new window I was trying to open, but the google window also automatically closes after 3 or 4 seconds.

    2.  I tried changing this line in rgvImportHeader_ItemDataBound event from

        ibtStatus.Attributes.Add("OnClick", "ShowImportDetail('" + strImportId + "');")
    to

    ibtStatus.Attributes.Add("OnClientClick", "ShowImportDetail('" + strImportId + "');")

    but then it wouldn't even call the java script function.  I am guessing you can't set the OnClientClick attribute in code behind?

    3.  I commented out the code in the rgvImportHeader_ItemDataBound event and just set the inline OnClientEvent on the image button as shown below, but again it opened the google window and then automatically closed it 3 or 4 seconds later.
    <asp:ImageButton ID="ibtPackageStatus"  runat="server"  ImageURL='<%# Bind("ImportStatusImage") %>'   OnClientClick="ShowImportDetail('xx');" />

    Any help would be greatly appreciated.
    Thank You

    Below is the code I am using to set the On Click event and the code for the page that is opening the window.

    Private Sub rgvImportHeader_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles rgvImportHeader.ItemDataBound
      
            If TypeOf e.Item Is GridDataItem Then
                Dim Row As GridDataItem = DirectCast(e.Item, GridDataItem)
                Dim strImportId As String = Row("ImportExecutionId").Text
                Dim ibtStatus As New ImageButton
                ibtStatus = DirectCast(Row.FindControl("ibtPackageStatus"), ImageButton)
                ibtStatus.Attributes.Add("OnClick", "ShowImportDetail('" + strImportId + "');")
      
            End If
      
        End Sub

    <%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/IPSMaster.Master" CodeBehind="WBC IMP Timberline Data.aspx.vb" Inherits="IPS_Gateway.WBC_IMP_Timberline_Data" %>
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="act" %>
      
    <asp:Content ID="cntMain" ContentPlaceHolderID="cphMainContent" runat="server">
      
        <script type="text/javascript">
            function ShowImportDetail(ExecutionId) {
                alert(ExecutionId);
                var oWnd = window.radopen("http://google.com","rwdImportDetail");
                oWnd.set_modal(true);
            }
        </script>
      
    <asp:SqlDataSource ID="SQLDS_ImportList"        runat="server"  ConnectionString="<%$ ConnectionStrings:IPSDataConnectionString %>"  SelectCommandType="StoredProcedure" SelectCommand="[Imports].[DSP_SELECT-ImportProcesses]" />                              
    <asp:SqlDataSource ID="SQLDS_ImportLogHeader"   runat="server"  ConnectionString="<%$ ConnectionStrings:IPSDataConnectionString %>"  SelectCommandType="StoredProcedure" SelectCommand="[Imports].[DSP_SELECT-ImportHeader]" />                                      
      
    <asp:panel ID="pnlPage"                                 runat="server"  SkinId="skn_GPC01_Panel_MainContent">
      
        <asp:panel ID="pnlPageHeader" runat="server"        cssClass="css_GPC01_Panel_PageHeading" >    
                    <telerik:RadToolBar ID="rtbImportData"  runat="server" AutoPostBack="false"  EnableEmbeddedSkins="True" OnButtonClick="rtbImportData_ButtonClick"  Skin="Black" >
                        <Items>
                            <telerik:RadToolBarButton runat="server" CommandName="tbtClearSelection"        ImageUrl="~/App_Themes/Images/Redo Undo/Undo Green 16.png"          Text="Clear Selected Items"     ToolTip="Clear Selected Itmes" />
                            <telerik:RadToolBarButton runat="server" CommandName="tbtRequeryImportDetail"   ImageUrl="~/App_Themes/Images/Reload/Reload Blue 16.png"            Text="Refresh Import Detail"    ToolTip="Requery Import Detail Grid" />
                            <telerik:RadToolBarButton runat="server" CommandName="tbtImportData"            ImageUrl="~/App_Themes/Images/Processing/Import Data Blue 16.ico"   Text="Import Data"              ToolTip="Import Data" />
                        </Items>
                    </telerik:RadToolBar>
            <asp:Label ID="txtPageTitle"             runat="server"     CssClass="css_GPC01_Label_PageTitle" Text="Import Timberline Data"/>   
            <asp:ImageButton ID="ibtPageInformation" runat="server"     SkinID="skn_GPC01_ImageButton_PageInformation"  />
            <asp:HiddenField ID="hdfObjectID"        runat="server" />
        </asp:panel>
      
        <asp:Panel ID="pnlPageContent" runat="server" cssClass="css_GPC01_Panel_PageContent" >        
            <asp:UpdatePanel ID="uppUpdateList" runat="server">
                <ContentTemplate>
                    <%-- Hidden fields are used to store the values for the select parameters for the SQLDataSource SQLDS_ImportLogHeader--%>
                    <asp:HiddenField ID="hdfStartId"    runat="server" Value="1"        EnableViewState="true" />
                    <asp:HiddenField ID="hdfEndId"      runat="server" Value="10000"    EnableViewState="true" />  
      
                    <asp:Label ID="lblRecordsSelected"          runat="server"  CssClass="css_GFS01_Label_Small"      Text="Records Selected:" />                                
                    <asp:TextBox ID="txtRecordsSelectedCount"   runat="server"  CssClass="css_GFS01_Text_MediumLeft"  Text="0"           Width="25px"  BorderStyle="None" />
                    <asp:TextBox ID="txtRecordsSelected"        runat="server"  CssClass="css_GFS01_Text_MediumLeft"  Width="740" />
                    <asp:TextBox ID="txtImportStatus"           runat="server"  CssClass="css_GFS01_Text_Status"      Text="Idle"        Width="100px"   />        
                    <telerik:RadGrid ID="rgvImportList"         runat="server"  DataSourceID="SQLDS_ImportList"       AllowPaging="True" ItemStyle-Wrap="false"  AutoGenerateColumns="False" Height="137px" Width="1038px"  PageSize="4" GridLines="None" Skin="Web20" >
                        <ItemStyle Wrap="False" />
                        <MasterTableView DataKeyNames="ImportID" DataSourceID="SQLDS_ImportList" >
                            <Columns>
                                <telerik:GridTemplateColumn                     UniqueName="chkSelectRow"   HeaderText=""               HeaderStyle-Width="20px" ItemStyle-Width="20px" ItemStyle-HorizontalAlign="Center" >
                                    <ItemTemplate>
                                        <asp:CheckBox ID="chkSelectRow"         runat="server"  AutoPostBack="true"  OnCheckedChanged="chkSelectRow_OnCheckChanged" />
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn
                                <telerik:GridTemplateColumn                     UniqueName="ImportStatus"   HeaderText="Req Status"     HeaderStyle-Width="90px"  HeaderStyle-HorizontalAlign="Center"  >
                                    <ItemTemplate>
                                        <asp:ImageButton ID="ibtRequestStatus"  runat="server" ImageURL='<%# Bind("RequestStatusImage") %>' />
                                        <asp:Label ID="lblRequestStatus"        runat="server" Text='<%# Bind("RequestStatus") %>' />
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn
                                <telerik:GridBoundColumn DataField="ImportID"   UniqueName="ImportID"       HeaderText="ID"             HeaderStyle-Width="30px"   HeaderStyle-HorizontalAlign="Left"   DataType="System.Int32"/>
                                <telerik:GridBoundColumn DataField="ImportName" UniqueName="ImportName"     HeaderText="Import Name"    HeaderStyle-Width="120px"  HeaderStyle-HorizontalAlign="Left"   ItemStyle-HorizontalAlign="Left"  />
                                <telerik:GridTemplateColumn                     UniqueName="ImportStatus"   HeaderText="Status"         HeaderStyle-Width="100px"  HeaderStyle-HorizontalAlign="Center" >
                                    <ItemTemplate>
                                        <asp:ImageButton ID="ibtImportStatus"   runat="server" ImageURL='<%# Bind("ExecutionStatusImage") %>' />
                                        <asp:Label ID="lblImportStatus"         runat="server" Text='<%# Bind("LastExecutionStatus") %>' />
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn
                                <telerik:GridBoundColumn DataField="LastExecutedBy"              UniqueName="LastExecutedBy"                HeaderText="Executed By"        HeaderStyle-Width="110px" HeaderStyle-HorizontalAlign="Left"  ItemStyle-HorizontalAlign="Left" />
                                <telerik:GridBoundColumn DataField="LastExecutionStartTime"      UniqueName="Start Date"                    HeaderText="Start Date"         HeaderStyle-Width="80px"  HeaderStyle-HorizontalAlign="Left"                                    DataType="System.DateTime" DataFormatString="{0:MM/dd/yy}"/>
                                <telerik:GridBoundColumn DataField="LastExecutionStartTime"      UniqueName="LastExecutionStartTime"        HeaderText="Start Time"         HeaderStyle-Width="70px"  HeaderStyle-HorizontalAlign="Right" ItemStyle-HorizontalAlign="Right" DataType="System.DateTime" DataFormatString="{0:h:mm:ss t}" />
                                <telerik:GridBoundColumn DataField="LastExecutionEndTime"        UniqueName="LastExecutionEndTime"          HeaderText="End Time"           HeaderStyle-Width="70px"  HeaderStyle-HorizontalAlign="Right" ItemStyle-HorizontalAlign="Right" DataType="System.DateTime" DataFormatString="{0:h:mm:ss t}"   />
                                <telerik:GridBoundColumn DataField="LastExecutionTimeElapsed"    UniqueName="LastExecutionTimeElapsed"      HeaderText="Time Elapsed"       HeaderStyle-Width="130px" HeaderStyle-HorizontalAlign="Left"  ItemStyle-HorizontalAlign="Left"  />
                                <telerik:GridBoundColumn DataField="ExecutionCount"              UniqueName="ExecutionCount"                HeaderText="Exec #"             HeaderStyle-Width="60px"  HeaderStyle-HorizontalAlign="Right" ItemStyle-HorizontalAlign="Right" DataType="System.Int32"  />
                                <telerik:GridBoundColumn DataField="AverageExecutionTimeElapsed" UniqueName="AverageExecutionTimeElapsed"   HeaderText="Avg Time Elapsed" />
                            </Columns>
                        </MasterTableView>
                        <ClientSettings AllowColumnsReorder="false" ReorderColumnsOnClient="false" Scrolling-AllowScroll="True" Scrolling-UseStaticHeaders="True"  Selecting-AllowRowSelect="True" />
                    </telerik:RadGrid>
                </ContentTemplate>
            </asp:UpdatePanel>
      
                    <br />            
                    <telerik:RadGrid ID="rgvImportHeader" runat="server"  ShowGroupPanel="False" Height="380px" Width="1038px" Skin="Web20" EnableViewState ="true">
                        <MasterTableView DataSourceID="SQLDS_ImportLogHeader"  
                            AutoGenerateColumns="false" DataKeyNames="ImportExecutionID" AllowPaging="true" ItemStyle-Wrap="false" PageSize="20"   
                            Caption="<span style='font-weight:bold'>Import Header</span>" >
                            <RowIndicatorColumn HeaderStyle-Width="10px" ItemStyle-BackColor="#FFFFF" />
                            <Columns>
                                <telerik:GridTemplateColumn                             UniqueName="ImportStatus"       HeaderText="Status"         HeaderStyle-Width="100px"   HeaderStyle-HorizontalAlign="Center"  >
                                    <ItemTemplate>
                                        <asp:ImageButton ID="ibtPackageStatus"  runat="server"  ImageURL='<%# Bind("ImportStatusImage") %>'   />
                                        <asp:Label ID="lblImportStatus"         runat="server"  Text='<%# Bind("ImportStatus") %>' />
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn>
                                <telerik:GridBoundColumn DataField="ImportExecutionID"  UniqueName="ImportExecutionID"  HeaderText="Execution Id"   Display="false"  />
                                <telerik:GridBoundColumn DataField="ImportId"           UniqueName="ImportId"           HeaderText="Id"             HeaderStyle-Width="30px"    HeaderStyle-HorizontalAlign="Center"    DataType="System.Int32"  />
                                <telerik:GridTemplateColumn                             UniqueName="Process Name"       HeaderText="Status"         HeaderStyle-Width="120px"   HeaderStyle-HorizontalAlign="Center" >
                                    <ItemTemplate>
                                         <asp:Label ID="lblImportName"  runat="server" Text='<%# Bind("ImportName") %>' />
                                    </ItemTemplate>
                                      
                                </telerik:GridTemplateColumn>
                                <telerik:GridBoundColumn DataField="ImportErrorCount"   UniqueName="ImportErrorCount"   HeaderText="Errors"         HeaderStyle-Width="50px"    HeaderStyle-HorizontalAlign="Center"    ItemStyle-HorizontalAlign="Right"   DataType="System.Int32" />
                                <telerik:GridBoundColumn DataField="SystemUser"         UniqueName="SystemUser"         HeaderText="User"           HeaderStyle-Width="100px"   HeaderStyle-HorizontalAlign="Left"   />
                                <telerik:GridBoundColumn DataField="ImportStartTime"    UniqueName="ImportStartDate"    HeaderText="Import Date"    HeaderStyle-Width="90px"    HeaderStyle-HorizontalAlign="Center"    ItemStyle-HorizontalAlign="Center"  DataFormatString="{0:MM/dd/yy}"     DataType="System.DateTime" />
                                <telerik:GridBoundColumn DataField="ImportStartTime"    UniqueName="ImportStartTime"    HeaderText="Start Time"     HeaderStyle-Width="80px"    HeaderStyle-HorizontalAlign="Right"     ItemStyle-HorizontalAlign="Right"   DataFormatString="{0:h:mm:ss t}"    DataType="System.DateTime" />
                                <telerik:GridBoundColumn DataField="ImportEndTime"      UniqueName="ImportEndTime"      HeaderText="End Time"       HeaderStyle-Width="80px"    HeaderStyle-HorizontalAlign="Right"     ItemStyle-HorizontalAlign="Right"   DataFormatString="{0:h:mm:ss t}"    DataType="System.DateTime" />
                                <telerik:GridBoundColumn DataField="ImportTimeElapsed"  UniqueName="ImportTimeElapsed"  HeaderText="Time Elapsed"   HeaderStyle-Width="120px"   HeaderStyle-HorizontalAlign="Left"   />
                                <telerik:GridBoundColumn DataField="ArgusStatus"        UniqueName="ArgusStatus"        HeaderText="Argus Status"   HeaderStyle-Width="150px"   HeaderStyle-HorizontalAlign="Left"  />
                                <telerik:GridBoundColumn DataField="ArgusStartTime"     UniqueName="ArgusStartTime"     HeaderText="Start Time"     HeaderStyle-Width="80px"    HeaderStyle-HorizontalAlign="Right"     ItemStyle-HorizontalAlign="Right"   DataFormatString="{0:h:mm:ss t}"    DataType="System.DateTime" />
                                <telerik:GridBoundColumn DataField="ArgusEndTime"       UniqueName="ArgusEndTime"       HeaderText="End Time"       HeaderStyle-Width="80px"    HeaderStyle-HorizontalAlign="Right"     ItemStyle-HorizontalAlign="Right"   DataFormatString="{0:h:mm:ss t}"    DataType="System.DateTime" />
                                <telerik:GridBoundColumn DataField="ArgusTimeElapsed"   UniqueName="ArgusTimeElapsed"   HeaderText="Time Elapsed"   HeaderStyle-Width="120px"   HeaderStyle-HorizontalAlign="Left"   />
                                <telerik:GridBoundColumn DataField="PackageStatus"      UniqueName="PackageStatus"      HeaderText="Package Status" HeaderStyle-Width="150px"   HeaderStyle-HorizontalAlign="Left"   />
                                <telerik:GridBoundColumn DataField="PackageStartTime"   UniqueName="PackageStartTime"   HeaderText="Start Time"     HeaderStyle-Width="80px"    HeaderStyle-HorizontalAlign="Right"     ItemStyle-HorizontalAlign="Right"   DataFormatString="{0:h:mm:ss t}"    DataType="System.DateTime" />
                                <telerik:GridBoundColumn DataField="PackageEndTime"     UniqueName="PackageEndTime"     HeaderText="End Time"       HeaderStyle-Width="80px"    HeaderStyle-HorizontalAlign="Right"     ItemStyle-HorizontalAlign="Right"   DataFormatString="{0:h:mm:ss t}"    DataType="System.DateTime" />
                                <telerik:GridBoundColumn DataField="PackageTimeElapsed" UniqueName="PackageTimeElapsed" HeaderText="Time Elapsed"   headerStyle-Width="120px"   HeaderStyle-HorizontalAlign="Left"   />
                            </Columns>
                        </MasterTableView>
                        <ClientSettings AllowColumnsReorder="false" EnablePostBackOnRowClick="true" AllowDragToGroup="false" ReorderColumnsOnClient="false" Selecting-AllowRowSelect="True" Scrolling-AllowScroll="True" Scrolling-UseStaticHeaders="True"  />
                    </telerik:RadGrid>
       
       <telerik:RadWindowManager ID="rwmImportDetail" runat="server" Behaviors="Close, Move, Resize,Maximize" DestroyOnClose="true" >
       </telerik:RadWindowManager>
        </asp:Panel>
      
      
    </asp:panel>
    </asp:Content>
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 04 Jan 2011 Link to this post

    Hello Tracy,

    This behavior is because of the postback after the window opened. Adding  "return false;"  will cancel the postback and thereby the window remains on page. Sample code shown below:

    from code behind:
    Button2.Attributes.Add("onclick", "orderMaintenanceOpenWindow;return false;");

    from Aspx:
    <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="orderMaintenanceOpenWindow(); return false; " />


    -Shinu.
  3. Tracy
    Tracy avatar
    123 posts
    Member since:
    Nov 2010

    Posted 04 Jan 2011 Link to this post

    Thank You
  4. Marbry
    Marbry avatar
    26 posts
    Member since:
    Aug 2012

    Posted 23 Aug 2011 Link to this post

    Any suggestion for doing that, except with a RadButton?

    I'm having the same problem.  It won't let me put the "return false;" in with the function name.  And it won't let me call args.set_cancel(false); in the handler since it's not cancellable.
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 24 Aug 2011 Link to this post

    Hello Marbry,

    RadControls take default parameters sender and arguments.It is not available for normal asp controls.So you cannot use args.set_cancel(false) if you are using normal asp control.
    Check the following documentation which explains opening windows.
    Opening Windows

    Thanks,
    Shinu.
  6. Marin Bratanov
    Admin
    Marin Bratanov avatar
    4630 posts

    Posted 25 Aug 2011 Link to this post

    Hi Marbry,

    f you wish to use set_cancel(true) you need to add the handler to the OnClientClicking event of the RadButton, as it is the cancellable event.

    If you use the OnClientClicked you would need to set the AutoPostBack property and set it to false to prevent the postback.


    Best wishes,
    Marin
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Back to Top