Re: how to change an image url at runtime

Discussion in 'ASP .Net' started by Mark Kamoski, Jul 20, 2003.

  1. Mark Kamoski

    Mark Kamoski Guest

    ....argghhh...

    ....still cannot figure this out...

    ....any help is appreciated...


    "Mark Kamoski" <> wrote in message
    news:...

    Ugg.

    Is there another way to do this without using Response.Write?

    Why doesn't something like this work?

    This code is in the code-behind for the user control for the Nav, which
    SHOULD swap the a top banner image.

    Why doesn't it work?

    What do you think?

    (Note-- I don't see where a Response.Write will help in this case.

    (I suspect this has something to do with postback, the event cycle of the
    host page, the event cycle of the user control, or something related to
    these-- but, I don't know exactly where.)

    //This is an image button event handler that exists in the user control.
    //The image button exists on the user control.
    //
    private void ShowFeedback_Click(object sender,
    System.Web.UI.ImageClickEventArgs e)
    {
    ShowBanner("Feedback");
    Response.Redirect("Feedback.aspx?Nav=Feedback");
    }

    //This is the helper method that exists in the user control.
    //
    private void ShowBanner(string NavValue)
    {
    TopBanner.ImageUrl = "Images/BannerTop" + NavValue + ".gif";
    }




    "Jon Davis" <> wrote in message
    news:O%...
    Try:

    Response.Write("<script>TopBanner.src =
    \"http://www.site.com/image.gif\";</script>");

    Jon


    "Mark Kamoski" <> wrote in message
    news:%...
    > How can one change an image url at runtime?
    >
    > (Note, the image exists in a user control.)
    >
    > This is the image tag on the ascx...
    >
    > <asp:image id="TopBanner" runat="server"></asp:image>
    >
    > ...but I cannot get this to change from the code behind of a page that
    > hosts the user control.
    >
    > Any ideas?
    >
    > Thanks.
    >
    >
    >
    Mark Kamoski, Jul 20, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    720
    Wee Bubba
    Jan 27, 2005
  2. ISGADMIN

    How to change the URL of a web reference at runtime?

    ISGADMIN, Nov 2, 2004, in forum: ASP .Net Web Services
    Replies:
    2
    Views:
    676
    ISGADMIN
    Nov 2, 2004
  3. Gujju

    Change URL of Web service at Runtime

    Gujju, May 30, 2005, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    133
    Gujju
    May 30, 2005
  4. Gujju

    Change url of web service at runtime

    Gujju, May 30, 2005, in forum: ASP .Net Web Services
    Replies:
    2
    Views:
    187
    Chris Hayes
    May 31, 2005
  5. change web service URL at runtime

    , Jul 6, 2006, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    162
    Vijay Pandey
    Jul 7, 2006
Loading...

Share This Page