2010-12-21 110 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与查询字符串的数据。

相关问题