简体   繁体   English

浏览可点击的图像按钮

[英]Navigate on clickable Imagebutton

I have an ImageButton1 and ImageButton1_Click event. 我有一个ImageButton1和ImageButton1_Click事件。 The Image is clickable, and when i click on it the Event fires up... 图片是可点击的,当我点击它时,事件触发...

Doing this works: 做到这一点:

Response.Redirect("secondPage.aspx"); 

But, I would like to load it with : 但是,我想加载它:

ImageButton1.NavigationUr = "some url";

how can I have a dynamic link? 如何获得动态链接?

Try the ImageButton1.DescriptionUrl property. 尝试使用ImageButton1.DescriptionUrl属性。 Set the url on runtime and redirect using the below code. 在运行时设置URL,并使用以下代码重定向。

protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
    Response.Redirect(ImageButton1.DescriptionUrl);
}

HyperLink控件可能适合:

<asp:HyperLink ID="whatever" runat="server" ImageUrl="/foo.png" NavigateUrl="some url" />

使用Firebug查找在imagebutton上设置的确切ID和属性(或为方便客户端访问而设置cssClass),然后在需要时使用javascript或jquery设置导航属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM