Skip to content

Adding <a> tag to image

Vipul Kelkar

Asked Mar 25, 2009, 1:22 AM EDT3 answers
Share
LinkedInX

Hi guys...i am displaying some html images on the web page dynamically...i want to add an tag to that image so that the user would be able to click on the image and navigate...

How can we add a tag in C# code

3 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    Hai man

    Use ImageButton in the toolbox option and in Properties of it....use
    ImageUrl-The Image u want to display
    PostbackUrl-The page u want to navigate to...

    Hope it Helps.........
    0
  • 0

    Soory dude...not workin

    No need o using toolbox...I have taken an array of 'image' control as i have to add the images dynamically...How can i navigate on the click of an image

    there is no property for an image control as postbackurl...

    Help me out..its urgent

    0
  • Niradhip Chakraborty
    0

    HTML code:
          

                                                       
                                                       
     
                                                           
     
                                                       

                                                                                                    
                                                   

     

    c# code:

    now you can fetch all the images path which is stored in database  and put it on a dataset and loop through it and assign the appropriate imagepath.

    Code
    imgEvent4.ImageUrl = dstEvents.Tables["Events"].Rows[intIndex]["evm_txt_EventImagePath"].ToString();
    
    for onclick option you can go for javascript.
    c# code:
    trEvent4.Attributes.Add("onclick", "ImageClick();");


    javascript code:

    Code
    function ImageClick()
        {
            location.href = "Image1.aspx";
            return false;
    
        }
    0