473,786 Members | 2,660 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 20685
Try:

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

Jon
"Mark Kamoski" <mk******@yahoo .com> wrote in message
news:%2******** ********@TK2MSF TNGP10.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******** ******@tk2msftn gp13.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_Cl ick(object sender,
System.Web.UI.I mageClickEventA rgs e)
{
ShowBanner("Fee dback");
Response.Redire ct("Feedback.as px?Nav=Feedback ");
}

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


"Jon Davis" <jo*@REMOVE.ME. PLEASE.jondavis .net> wrote in message
news:O%******** ********@TK2MSF TNGP11.phx.gbl. ..
Try:

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

Jon
"Mark Kamoski" <mk******@yahoo .com> wrote in message
news:%2******** ********@TK2MSF TNGP10.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
8535
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 like "gcnew is undeclared error",how to deeclare 'gcnew" and when i am using in runtime to change the size of images in imagelist in listview control in .net(forms application) by chnging one trckbar(like tb1->Value),
3
2864
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 runtime then I create an Image control (from WebControls collection) and add it to the page also at runtime. The ImageUrl property needs a URL string but I only have the image itself extracted with a data RecordSet (recordset for example.) Can...
7
1685
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) .Width = 72 .Height = 101 .BackColor = Color.Transparent .BorderStyle = BorderStyle.None
2
8661
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 ? More thanks Tommy
5
2575
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" src="../../images/helloworld.jpeg"/> But this gives this error: File '../../images/helloworld.jpeg' was not found
4
3135
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 know I can create a new master page, but I'd like to just change the master page from the content page if possible. thanks!
7
19325
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 display one by one automatically with correct resized image please help thanks in advances
4
5035
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 I need to convert dinamically a Form.Icon to Button.Image runtime, but i don't know how. Any help would be appreciated. Many Thanks
1
2900
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 Imagepath to the PictureBox.
0
9655
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9497
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9964
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6749
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4067
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.