473,400 Members | 2,163 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,400 software developers and data experts.

how to change an image url at runtime

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.

Nov 15 '05 #1
2 20657
Try:

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

Jon
"Mark Kamoski" <mk******@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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.

Nov 15 '05 #2

....argghhh...

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

....any help is appreciated...
"Mark Kamoski" <mk******@yahoo.com> wrote in message
news:Ok**************@tk2msftngp13.phx.gbl...

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" <jo*@REMOVE.ME.PLEASE.jondavis.net> wrote in message
news:O%****************@TK2MSFTNGP11.phx.gbl...
Try:

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

Jon
"Mark Kamoski" <mk******@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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.


Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Sanjeeva Reddy | last post by:
hai Anti Keskinen, i have used the following code MyListView->LargeImageList->ImageSize = gcnew System::Drawing::Size(100, 100); // Sets large image size to 100, 100 here i am getting error...
3
by: Jake | last post by:
I am a beginner in C# and web controls. I need a way to load an image which is stored in an Access (mdb) field into an Image control added at runtime. I get the image (jpg format) dynamically at...
7
by: Adam Maltby | last post by:
Hi, I am adding an new picbox and animated gif to it at runtime Dim img As Image = Image.FromFile(Application.StartupPath & "\animation.gif") With pic_Wait .Location = New Point(300, 250)...
2
by: Tommy | last post by:
Hi all, I use DataGridView in my form and add image column and 2 textbox column, and I want to change image column's image on runtime. But there is no any example on this function. What can I do ?...
5
by: Jeff | last post by:
Hey asp.net 2.0 I have a webpage which generate thumbnail images. In another webpage I want to display these images... I tryed using this solution: <img ID="photo"...
4
by: David Lozzi | last post by:
Howdy, I have my master page, and I would like to change the background CSS class per the content page. Only the home page has a different background style, all other pages are using the same. I...
7
by: kadarkarai | last post by:
I am developing photo gallery in Macromedia Flash 8 and XML to retrive the Image. Image Size is all in different size. my question is How to Change image size at runtime in flash? so that image...
4
by: Marcolino | last post by:
Hi, I have simple needs but I don't know how to implement it. I have application that create Dynamic Button. I need to set the image on this button, getting the icon from a form. So pratically...
1
by: Krushangi | last post by:
Hi Code for: How to change picturebox during Runtime. I want this Code in C#.net I have one picturebox Image and i want to change it during MouseUp Event at Runtime. Tell me how can i give...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.