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

Opening window from a grid

1 Answer 49 Views
Window
This is a migrated thread and some comments may be shown as answers.
Clive Hoggar
Top achievements
Rank 1
Clive Hoggar asked on 07 Dec 2009, 04:14 PM
Hi
I hope someone can help - I think I am list in syntax issues with this.
Trying to use showWindow(url) method to pass a record ID to the window.

I have this column in  a radgrid:
<telerik:GridTemplateColumn DataField="ID" DataType="System.Int32" SortExpression="ID" UniqueName="ID">  
    <ItemTemplate> 
      <asp:HyperLink ID="HyperLink1" runat="server"   
        NavigateUrl='<%# "javascript:onclientclick=showWindow('../podcast-player/play-podcast.aspx?ID=" & Eval("ID") & "');" %>'>Listen</asp:HyperLink>    
       </ItemTemplate> 
</telerik:GridTemplateColumn> 

and my javascript and window declaration:
<script type="text/javascript" language="javascript">  
     function showWindow(url) {  
         var oWnd = $find("<%=RadWindow1.ClientID%>");  
         oWnd.setUrl(url);  
         oWnd.show();  
     }  
     function OnClientClose(oWnd) {  
         oWnd.setUrl("about:blank"); // Sets url to blank      
     }     
</script>   
<telerik:RadWindow ID="RadWindow1" runat="server" Skin="Vista" Behaviors="Move,Close,Resize" VisibleStatusbar="False"   
Animation="Fade" Height="170px" Width="280px" 
                    OnClientClose="OnClientClose">  
                </telerik:RadWindow>              

The problem is 'the server tag is not well formed' at runtime.   I tried replacing the regular apostrophes inside the showWindow('....') with a different type of apostrophe (`), which removed the runtime error message, but the link does not do anything when clicked.

Please help me out of the syntax (I think) mire!

Thanks

Clive

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 08 Dec 2009, 06:30 AM
Hello Clive,

Try out the following code snippet.

ASPX:
 
<telerik:GridTemplateColumn DataField="ID" DataType="System.Int32" SortExpression="ID" 
        UniqueName="ID"
        <ItemTemplate> 
            <asp:HyperLink ID="HyperLink1" runat="server">Listen</asp:HyperLink> 
        </ItemTemplate> 
    </telerik:GridTemplateColumn> 

CS:
 
    protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem item = (GridDataItem) e.Item; 
            HyperLink editLink = (HyperLink)e.Item.FindControl("HyperLink1"); 
            editLink.Attributes["href"] = "#"
            editLink.Attributes["onclick"] = "return ShowEditForm('Default.aspx?id=" + item.GetDataKeyValue("ID").ToString() + "');"
        } 
    } 
[Note: Set the DataKeyNames as ID in order to get the DataKeyValue]

Also checkout the following demo which demonstrates same functionality.
Grid / Window Editing

-Shinu.
Tags
Window
Asked by
Clive Hoggar
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or