how to change images in masterpage using java script?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shashank narayan
    New Member
    • Mar 2010
    • 11

    how to change images in masterpage using java script?

    i m using a master page in my project and that page contains an image tag . i want to change images in that image tag by using java script after fixed time interval. my technology is asp.net. is it possible ? and those changed images should be work in all pages. so help me ???? bye
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    In your JavaScript you should use the document.getEle mentById('id') method to get a reference to the image tag that you want to work with. You can change the element's src property to change the image via JavaScript.

    The tricky part is knowing how to retrieve the "id" for the image element.

    If your image is an ASP.NET Image control then the "id" that you want to supply to the document.getEle mentById() method is the image control's ClientID property.

    If your image is a pure HTML <img> tag then you supply the id that you gave this image to the getElementById method.

    It is probably better to work with the ASP.NET Image control rather than use the HTML <img> tag because ASP.NET will assign unique IDs to the elements, making your HTML valid. Also, if you use the ASP.NET Image control you can access it in your C# or VB.NET server side code....

    Anyways, check out this quick article on How to use JavaScript in ASP.NET.

    -Frinny

    Comment

    • shashank narayan
      New Member
      • Mar 2010
      • 11

      #3
      thanks a lot i will try ur idea and will tell you later

      Comment

      Working...