REDIRECT FROM THE IMAGE BUTTON

Chintoo Semi

Total Post:135

Points:947
Posted by  Chintoo Semi
.NET  ASP.Net  C# 
 824  View(s)
Ratings:
Rate this:

I want to link a button to this website “http://www. timesofindia.indiatimes.com/” When the user clicks the image button. I have searched on the net and can't find an exact solution. This is what I have so far

<asp:ImageButton ID="ImgButtonTimesOfIndia" runat="server" ="~/Images/TimesOfIndia.png" Width="480px"/>

  1. Anchal Kesharwani

    Post:10

    Points:70
    Re: Redirect from the Image Button

    hi Chintoo,


    You  can use this code. I hope that it works for you.

    Either use the postback url

     

    <asp:ImageButton ID="ImgButtonTimesOfIndia" runat="server" ImageUrl="~/Images/TimesOfIndia.png"  PostBackUrl="http://www.timesofindia.com/" Width="480px" />

     

    Or

     

    ASPX Code

     

    <asp:ImageButton ID="ImgButtonTimesOfIndia" runat="server" ImageUrl="~/Images/TimesOfIndia.png" Width="480px" OnClick="ImgButtonTimesOfIndia_Click"/>

     

     cs file code

     

    protected void ImgButtonTimesOfIndia_Click(object sender, ImageClickEventArgs e)

       {

           Response.Redirect("http://www.timesofindia.com/");

     

       }

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!