2010-12-21 109 views
0


我一直在試2天。
在ASP.NET和VB.NET中我已page1.aspx和page2.aspx
我想當我按下page1.aspx button1觸發button1.click事件並在新窗口中打開page2.aspx和發送給它的數據。
如果沒有新的窗口,通過Server.Transfer或Response.Redirect,所有這些都可以輕鬆完成。
但不幸的是,他們沒有選擇打開一個新窗口。如何在新窗口中打開頁面併發送數據?

謝謝,

艾哈邁德。

- Updae -
我已經使用這個解決方案,但不能發送參數,它打開我頁0!

<asp:Button ID="Add" runat="server" Text="Add" OnClientClick ="return pageOpen(TextBox1.SelectedValue, TextBox2.SelectedValue);"/> 

和JavaScript是:

 <script type="text/javascript"> 
    function pageOpen() 
    { 
     window.open("page2.aspx?param1=" & arguments[0] & "&param2=" & arguments[1]) 
    } 
</script> 
+0

什麼叫頁0是什麼意思?您的javascript pageOpen沒有定義參數.... – XtremeBytes 2010-12-21 20:11:26

+0

我無法發送參數到函數pageOpen(),所以它爲我打開這樣一個頁面:http:// mysite/0,但是如果我硬編碼了參數window.open然後在新窗口中打開page2.aspx。 – Ahmed 2010-12-21 21:26:24

回答

2
function openWindow() { 
window.open('Page2.aspx?Arg1=' + document.getElementById('<%= txt1.ClientID %>').value + '&Arg2=' + document.getElementById('<%= txt2.ClientID %>').value, 'Title'); 
} 


<asp:TextBox ID="txt1" runat="server" /> 
<asp:TextBox ID="txt2" runat="server" /> 
<asp:Button ID="btn" Text="Add" OnClientClick="openWindow()" runat="server" /> 

這應該工作...

2

你需要調用window.open在Javascript與查詢字符串的數據。

相關問題