2017-03-08 58 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