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

Open a window and pass a paramter

3 Answers 26 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Clive Hoggar
Top achievements
Rank 1
Clive Hoggar asked on 15 Feb 2010, 02:15 PM
I am trying to open a window from grid item to display additional info about the item.
To do that I need to pass the product name.

I am trying this, but at run time I get 'the tag is not well formed' .  

How can I do this correctly?

Thanks

Clive 

JAVASCRIPT  
 
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">  
    <script type="text/javascript" language="javascript">  
        function showWindow(url) {  
            var oWnd = $find("<%=RadWindow3.ClientID%>");  
            oWnd.setUrl(url);  
            oWnd.show();  
        }  
        function OnClientClose(oWnd) {  
            oWnd.setUrl("about:blank"); // Sets url to blank      
        }     
</script>   
    </telerik:RadCodeBlock> 
 
THE WINDOW  
 
<telerik:RadWindow ID="RadWindow3" runat="server"   
        Skin="Black" Behaviors="Move,Close,Resize" VisibleStatusbar="False"   
                    Animation="Fade"   
        IconUrl="~/images/favicon16.gif" Height="170px" Width="280px" 
                    OnClientClose="OnClientClose">  
                </telerik:RadWindow> 
 
 
THE GRID COLUMN  
 
<telerik:GridTemplateColumn DataField="Name"   
            HeaderText="Name" SortExpression="Name"   
            UniqueName="Name">  
            <EditItemTemplate> 
                <asp:TextBox ID="NameTextBox" runat="server"   
                    Text='<%# Bind("Name") %>'></asp:TextBox> 
            </EditItemTemplate> 
            <ItemTemplate> 
                <asp:HyperLink ID="HyperLink1" runat="server"   
                NavigateUrl="javascript:onclientclick=showWindow('../windows/en-primeur-tasting.aspx?Name=" & <%# Eval("Name") %> & "');"> 
                <%# Eval("Name") %> 
                </asp:HyperLink> 
                                
            </ItemTemplate> 
            <HeaderStyle Width="250px" /> 
        </telerik:GridTemplateColumn> 

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 16 Feb 2010, 07:12 AM
Hello Clive,

I tried code behind approach in order to pass the required parameter to open the window. Here is the code that I tried.

CS:
 
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem item = (GridDataItem)e.Item; 
            HyperLink lnk = (HyperLink)item.FindControl("HyperLink1"); 
            string value = "showWindow('Paging.aspx?cid=" + item["Name"].Text + "');"
            lnk.Attributes.Add("onclick", value); 
        } 
    } 

JavaScript:
 
        function showWindow(url) { 
            var oWnd = $find("<%=RadWindow3.ClientID%>"); 
            oWnd.setUrl(url); 
            oWnd.show(); 
        } 

ASPX:
 
    <telerik:GridTemplateColumn DataField="Name" HeaderText="Name" SortExpression="Name" UniqueName="Name"
        <ItemTemplate> 
            <asp:HyperLink NavigateUrl="#" ID="HyperLink1" runat="server">  
                 <%# Eval("Name")%>  
            </asp:HyperLink> 
        </ItemTemplate> 
        <HeaderStyle Width="250px" /> 
    </telerik:GridTemplateColumn> 

-Shinu.
0
Nikolay Rusev
Telerik team
answered on 16 Feb 2010, 07:20 AM
Hello Shinu,

You can simply use the following binding expression:
<ItemTemplate>
 <asp:HyperLink ID="HyperLink1" runat="server"                                 
  NavigateUrl='<%# "javascript:onclientclick=showWindow(\"../windows/en-primeur-tasting.aspx?Name=" + Eval("Name") +"\");" %>'>
 <%# Eval("Name")%>  
 </asp:HyperLink>  
</ItemTemplate>


Sincerely yours,
Nikolay
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Clive Hoggar
Top achievements
Rank 1
answered on 18 Feb 2010, 11:15 AM
Thanks!
Tags
Grid
Asked by
Clive Hoggar
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Nikolay Rusev
Telerik team
Clive Hoggar
Top achievements
Rank 1
Share this question
or