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

new window is not showing up

2 Answers 90 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Charlie
Top achievements
Rank 1
Charlie asked on 06 Jul 2011, 04:12 PM
I created a RadGrid and have a image button as a column; when I click image button, I need to open a new window with some existing page, passing some value.

Here's what I did. Please help:
1. created a RadGrid with OnItemCommand="RadGrid1_ItemCommand; and created a image button.

                <telerik:GridTemplateColumn AllowFiltering="false">
                    <ItemTemplate>
                        <asp:ImageButton ID="imgbtnEdit" ToolTip="Edit Solution" CommandName="modify" 
                            CommandArgument='<%# Bind("solution_id") %>' runat="server" ImageUrl="~/Images/edit.gif" />
                    </ItemTemplate>
                    <ItemStyle HorizontalAlign="Center" Width="2%"></ItemStyle>
                    <ItemStyle BorderStyle="Solid" HorizontalAlign="Left" VerticalAlign="Top" Width="1%" />

2.created .js file with following code
      function EditSolution(SolutionID)
      {
          var newWindow;
          var WindowName;
          WindowName = strSessionID + "EditSolution" + SolutionID;
          newWindow = window.open(
         strPublicMap + "/" + strDispLangCode + "/solutions/processsolution.asp?command=edit&solutionID=" + SolutionID,
         WindowName,
         "toolbar=yes,channelmode=no,menubar=yes,location=yes,directories=no,scrollbars=yes,resizable=yes,status=yes,height=470,width=750,left=1,top=1");
      }

 3. reference in .aspx file
<head id="Head1" runat="server">
    <title></title>
    <script language ="javascript"  type="text/javascript" src ="../Script/Home.js"></script> 
</head>

4. in code behind file

    Protected Sub RadGrid1_ItemCommand(ByVal source As Object, ByVal e As GridCommandEventArgs) Handles RadGrid1.ItemCommand

        Dim strCommandName As String = e.CommandName.ToLower()
        Dim sTitle As String = ""
        Dim intIndex As Integer

        If (strCommandName = "browse" Or strCommandName = "modify" Or strCommandName = "attachment") Then
            intIndex = Convert.ToInt32(e.CommandArgument)
            Select Case strCommandName
                Case "modify"
                    EditSolution(intIndex)
                Case "attachment"
            End Select
        End If

Protected Sub EditSolution(ByVal iSolutionID As Integer)
        Dim strScript As String = String.Empty

        strScript = "javascript:EditSolution(" & iSolutionID & ");"
        ScriptManager.RegisterStartupScript(Me.RadGrid1, Me.GetType, "OpenAttachments", strScript, True)
End Sub

The js file should be fine since it is used by production. I just start to use telerik grid. I believe last line code is wrong, but not sure how to fix it.         ScriptManager.RegisterStartupScript(Me.RadGrid1, Me.GetType, "OpenAttachments", strScript, True)
Thanks in advance!
 

2 Answers, 1 is accepted

Sort by
0
Charlie
Top achievements
Rank 1
answered on 06 Jul 2011, 08:29 PM
Any one can help with this? Basically, create a RadGrid,  and create a image button as a column and other data column; when click image button, should open a new window with some existing page.

Thanks, guys!

0
Pavlina
Telerik team
answered on 11 Jul 2011, 05:07 PM
Hello Charlie,

Please refer to the project attached in this forum post to see how the ScriptManager.RegisterStartupScript is called and let me know if it helps:
http://www.telerik.com/community/forums/aspnet/ajax/scriptmanager-registerstartupscript-not-working-properly-after-some-ajax-and-dopostback-calls.aspx

Best wishes,
Pavlina
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
Grid
Asked by
Charlie
Top achievements
Rank 1
Answers by
Charlie
Top achievements
Rank 1
Pavlina
Telerik team
Share this question
or