本文介绍了如何使用图像按钮,在另一个窗口中打开URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好我知道如何在超链接设置目标达致这= _blank,我怎么能做到这一点使用图像按钮控制,下面是我的code:
< ASP:ImageButton的的OnClick =test_Click的ImageUrl =/图像/联系我们/ directionbtn.pngID =测试=服务器的ValidationGroup =组2/ > < ASP:的RequiredFieldValidator ID =RequiredFieldValidator2=服务器
的ControlToValidate =txtPost code1的ErrorMessage =邮报code需要的ValidationGroup =组2>< / ASP:&的RequiredFieldValidator GT;
< BR />
背后code:
保护无效test_Click(对象发件人,ImageClickEventArgs E)
{ Response.Redirect(String.Format(\"http://maps.google.co.uk/maps?saddr={0}&daddr=&daddr=Wigan+WN6+0HS,+United+Kingdom&iwloc=1&dq=Tangent+Design\", txtPost code1.Text));}
任何帮助或建议将pciated高度AP $ P $
解决方案
保护无效的Page_Load(){
ControlID.Attributes.Add(目标,_blank);
}
如果不工作,你可以添加以下到您的ImageButton:
< ASP:ImageButton的=服务器的OnClientClick =window.open('的http:// URL /到/开');
Hi I know how to acheive this in hyperlink by setting target = _blank , how can i do this using image button control , below is my code:
<asp:ImageButton OnClick="test_Click" ImageUrl="/images/contactUs/directionbtn.png" ID="test" runat="server" ValidationGroup="group2" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="txtPostcode1" ErrorMessage="Postcode is required" ValidationGroup="group2"></asp:RequiredFieldValidator>
<br />
Code behind:
protected void test_Click(object sender, ImageClickEventArgs e)
{
Response.Redirect(String.Format("http://maps.google.co.uk/maps?saddr={0}&daddr=&daddr=Wigan+WN6+0HS,+United+Kingdom&iwloc=1&dq=Tangent+Design", txtPostcode1.Text));
}
Any help or advice will be highly appreciated
解决方案
protected void Page_Load() {
ControlID.Attributes.Add("target", "_blank");
}
If that doesn't work, try adding this to your ImageButton:
<asp:ImageButton runat="server" OnClientClick="window.open('http://url/to/open');
这篇关于如何使用图像按钮,在另一个窗口中打开URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!