在asp.net C#按钮点击重定向新的标签。(Response.Redirect的) [英] Redirecting new tab on button click.(Response.Redirect) in asp.net C#
问题描述
我试图打开新标签/窗口页面上的按钮click.I试图在谷歌得到了这个code,但它不工作。
任何人可以帮助我呢?
< ASP:按钮的ID =BTN=服务器文本=提交
的OnClick =btnNewEntry_Click的OnClientClick =aspnetForm.target ='_空白';/>保护无效btnNewEntry_Click(对象发件人,EventArgs的发送)
{
的Response.Redirect(CMS_1.aspx);
}
当我使用这个我得到错误说
微软JScript运行时错误:'aspnetForm'是不确定的。
我觉得你的code应该只是从这里取出的一件事,但它会从当前页面存在的窗口内完成重定向
< ASP:按钮的ID =BTN=服务器文本=提交 的OnClick =btnNewEntry_Click/>保护无效btnNewEntry_Click(对象发件人,EventArgs的发送)
{
的Response.Redirect(CMS_1.aspx);
}
和如果u想通过客户端脚本做这个
用这种方式
< ASP:按钮的ID =BTN=服务器文本=提交的OnClientClick =window.open('Default2.aspx')/>
据我你应该preFER的客户端脚本,因为刚刚打开一个新的窗口,服务器端将回发,这将是无用的。
I'm trying to open a page in new tab/window on button click.I tried in the google got this code but its not working.
Can anybody help me with this?
<asp:Button ID="btn" runat="Server" Text="SUBMIT"
OnClick="btnNewEntry_Click" OnClientClick="aspnetForm.target ='_blank';"/>
protected void btnNewEntry_Click(object sender, EventArgs e)
{
Response.Redirect("CMS_1.aspx");
}
When I use this I'm getting error saying
Microsoft JScript runtime error: 'aspnetForm' is undefined.
I think your code should work just remove one thing from here but it'll do redirection from current page within existing window
<asp:Button ID="btn" runat="Server" Text="SUBMIT"
OnClick="btnNewEntry_Click"/>
protected void btnNewEntry_Click(object sender, EventArgs e)
{
Response.Redirect("CMS_1.aspx");
}
And if u wanna do the this via client side scripting Use this way
<asp:Button ID="BTN" runat="server" Text="Submit" OnClientClick="window.open('Default2.aspx')" />
According to me you should prefer the Client Side Scripting because just to open a new window server side will take a post back and that will be useless..
这篇关于在asp.net C#按钮点击重定向新的标签。(Response.Redirect的)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!