2017-03-08 56 views
1

当我点击HyperLink时,我想用它打开一个弹出窗口。我怎样才能做到这一点?在asp.net中带有参数的超链接弹出

超链接例如为:

<asp:HyperLink ID="hplToplamBegeni" runat="server" NavigateUrl='<%# "../Yazar/PostLikes.aspx?PostID="+ Eval("PostID") %>'></asp:HyperLink> 
+1

[创建使用传递参数的PopUp的可能的副本](http://stackoverflow.com/questions/778000/create-popup-with-asphyperlink-that-is-passing-parameters) – Ethilium

+0

其实,我看到了这个链接。但是,当我尝试那种导致这样错误的解决方案时, “服务器标签格式不合适。”我用这样的代码; 'Target =“_ blank”>

回答

1

这个使用javascript的超链接应该适合你。

<asp:HyperLink runat="server" ID="hplToplamBegeni" Text="popup" 
NavigateUrl='<%# String.Format("../Yazar/PostLikes.aspx?PostID={0}", Eval("PostID"))%>' 
     onclick="javascript:w= window.open(this.href,'PostID', 
    'left=20,top=20,width=1500,height=300,toolbar=0,resizable=0');return false;"> 
</asp:HyperLink> 

如果还有其他问题。检查URL输入的路径是否正确,并且正确使用了PostID。

+0

是的,这是有效的,非常感谢 –

+0

不客气,很高兴帮助。 – Ethilium