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

open popup window on radgrid linkbutton click

3 Answers 933 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 25 Apr 2013, 02:36 PM
What I am trying to do is open a popup window on a linkbutton click on a radgrid.  Tried 2 methods and alls the page does is postback and produce no window.  What I would like is a window to open so that they can email someone from the window that pops up.

1st method, not working

<telerik:GridTemplateColumn HeaderText="RESCHEDULE">
                       <ItemTemplate>
                           <asp:ImageButton ID="imgSched" runat="server" CommandName="reSched" CommandArgument='<% #Bind("intEOLId") %>' ImageUrl="~/Images/Bones.png" OnClientClick="javascript:window.open('../Admin/Email.aspx?EolId);" Height="30px" Width="30px" />
                       </ItemTemplate>
                   </telerik:GridTemplateColumn>


2nd method not working
If (e.CommandName = "reSched") Then
           Dim EolId As Integer = Convert.ToInt32(e.CommandArgument)
           Dim item As GridDataItem = TryCast(e.Item, GridDataItem)
           Dim linkSched As ImageButton = DirectCast(item.FindControl("imgSched"), ImageButton)
           Dim Vreturn As String = ""
 
 
           linkSched.Attributes.Add("onclick", "javascript:window.open('../Admin/Email.aspx?EolId=" & EolId & "'); return false;")
 
           'sql = "Execute usp_EOLResched " & EolId
 
           'Vreturn = getData(sql).Rows(0)(0)
 
           'If Vreturn = "1" Then
           '    Fillgrid = True
           '    myRadGrid.Rebind()
           'End If
 
       End If

3 Answers, 1 is accepted

Sort by
0
Kevin
Top achievements
Rank 1
answered on 25 Apr 2013, 05:02 PM
Ok, i changed this all to use a telerik radWindow, so that I could use on page and things just look better, however unlike a asp modalpopup I am having trouble with it opening from the code behind.  I need to pass some values to it and have it open with some information filled out already but it does not seem to open.
If (e.CommandName = "Sched") Then
          Dim EolId As Integer = Convert.ToInt32(e.CommandArgument)
          Dim Vreturn As String = ""
          FIndEmail()
 
          radEmail.Modal = True
          'sql = "Execute usp_EOLResched " & EolId
 
          'Vreturn = getData(sql).Rows(0)(0)
 
          'If Vreturn = "1" Then
          '    Fillgrid = True
          '    myRadGrid.Rebind()
          'End If
 
      End If

 

Tried radmail.visible = true as well and did not work.

I can open this up via javascript method.

<script type="text/javascript">
 
       function addAdminWin() {
           var addAdmin = $find("<%= radEmail.ClientID %>");
          addAdmin.show();
      }
  </script>

 

The problem is that I need it to fill out this in the email box that I need to pass in a function in the code behind, if there is a way to pass in the findEmial function from code behind then this methos will work.

0
Kevin
Top achievements
Rank 1
answered on 25 Apr 2013, 05:53 PM
Ok stuck here for hooking the radwind up to a service to pull back the persons I am sending the email to and from.

 

<telerik:GridTemplateColumn HeaderText="RESCHEDULE">
                       <ItemTemplate>
                               <asp:ImageButton ID="imgSched" runat="server" ImageUrl="~/Images/Bones.png" Height="30px" Width="30px"  OnClientClick='<%# String.Format("addAdminWin({0}, {1}); return false;", Eval("intEOLId"), 2)%>' />
                       </ItemTemplate>
                   </telerik:GridTemplateColumn>
 
 
 
<script type="text/javascript">
 
        function addAdminWin(EolId, Switch) {
            var addAdmin = $find("<%= radEmail.ClientID %>");
           addAdmin.show();
       }
   </script>

How can I point to my asmx service page and pull the following service from it.

<WebMethod()> _
  Public Function FIndEmail(ByVal EoldId As Integer, ByRef PersID As Integer) As String()
      Dim items As New List(Of String)
 
      sql = "Select strFTEmail from where intPersonnelId = " & PersID
 
      myDataTable = New DataTable
      myDataTable = getData(sql)
 
      If myDataTable.Rows.Count > 0 Then
          For Each dRow As DataRow In myDataTable.Rows
              items.Add(dRow("strFTEmail"))
          Next
      End If
 
      Return items.ToArray
  End Function

 

 

 

 


0
Accepted
Shinu
Top achievements
Rank 2
answered on 26 Apr 2013, 06:28 AM
Hi,

one suggestion is that you can pass the datakeyname as shown below.
aspx:
<MasterTableView DataKeyNames="intEOLId" >

VB:
Protected Sub RadGrid1_ItemCommand(sender As Object, e As GridCommandEventArgs)
    If e.CommandName = "commandname" Then
        Dim item As GridDataItem = TryCast(e.Item, GridDataItem)
        Dim linkSched As ImageButton = DirectCast(item.FindControl("imgSched"), ImageButton)
        Dim value As String = item.GetDataKeyValue("intEOLId").ToString()
    linkSched.Attributes.Add("onclick", "open('" + value + "');return false;")
    End If
End Sub

JS:
function open(value) {
      window.radopen("Page.aspx?ID=" + value, "RadWindow1");
  }

Thanks
Shinu
Tags
Grid
Asked by
Kevin
Top achievements
Rank 1
Answers by
Kevin
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or