Antonio Mailtraq
Antonio Mailtraq

Reputation: 1407

Popup window from asp:Hyperlink with parameter in c#

I need open in my GridView the asp:Hyperlink with parameter to window popup.

Here is a working sample for a popup window with parameter, but I have error.

The error message says:

Server tag is not correctly formatted.

What's the problem ?

How to do resolve this ?

Can you help me ?

Thank you in advance.

My code below.

<asp:TemplateField HeaderText="btest">
    <ItemTemplate>
        <asp:HyperLink runat="server" ID="btest" Text="btest"
         NavigateUrl='<%#"javascript:_popupWin=window.open('btest.aspx?Sample_ID=" + Eval("Sample_ID") + "',
         '_popupWin','width=300,height=300,resizable=yes,location=yes,scrollbars=yes');_
         popupWin.focus();" %>'>
       </asp:HyperLink>
    </ItemTemplate>
</asp:TemplateField>

Upvotes: 1

Views: 1275

Answers (1)

Hamamelis
Hamamelis

Reputation: 2113

Try this :

<asp:TemplateField HeaderText="btest">
    <ItemTemplate>
        <asp:HyperLink runat="server" ID="btest" Text="btest"

        NavigateUrl='<%# String.Format("btest.aspx?sID={0}", Eval("Sample_ID"))%>' 
        onclick="javascript:w= window.open(this.href,'Sample_ID',
       'left=20,top=20,width=1500,height=300,toolbar=0,resizable=0');return false;">

       </asp:HyperLink>
    </ItemTemplate>
</asp:TemplateField>

Upvotes: 1

Related Questions