【发布时间】:2011-08-10 10:20:04
【问题描述】:
您好,我知道如何通过设置 target = _blank 在超链接中实现这一点,我如何使用图像按钮控件来做到这一点,下面是我的代码:
<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 />
后面的代码:
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));
}
任何帮助或建议将不胜感激
【问题讨论】:
-
使用锚点作为图像的容器。还是 asp.net 行话,
-
当前链接在同一页面上打开
-
我需要将 txtpostcode 值传递给链接,然后我将如何实现 4
-
ok... 在 javascript 中执行
在 javascript: foo(){ var txtPostCode = document.getElementById('txtPostcode1').value; window.open("maps.google.co.uk/maps?saddr=" + txtPostcode1 + "&daddr=&daddr=Wigan+WN6+0HS,+United+Kingdom&iwloc=1&dq=Tangent+Design"","MyWindow","height=375,width=350") ; } // 不要忘记验证 if(txtPostcode1 !== ''){foo();} -
使用脚本验证组不起作用
标签: asp.net validation imagebutton new-window