simple question: How to refer to an image on the header control?

T

tom

Hi,

I am a newbie and have a simple question?
I have a aspx file and on the form I have a user control which is my
header and has some images. Now for various pages I need to load
different images on the header. How to replace image "A" with image "B"
on the control programatically?

I Use C# and Visual Studio 2005.

Any help is greatly appreciated,
Tom
 
T

Teemu Keiski

Hi,

you could have a property in the UC which is mapped to the ImageUrl (e.g if
you have a Image control in the user control) and this property could be set
by the Page. If you have Image with ID "Image1" in the user control, you
could have a property
public string ImageUrl
{
get
{
return Image1.ImageUrl;
}
set
{
Image1.ImageUrl = value;
}
}

And this then could be set by the Page with <UserControlID>.ImageUrl="url to
the img"; For example if you have it on Page

<uc1:WebUserControl1 ID="ucHeader" runat="server" />

then set in code

ucHeader.ImageUrl = "images/image.gif";

(you would need to have a member with UC's type in page's code-behind if you
use ASP.NET 1.1)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,998
Messages
2,570,242
Members
46,834
Latest member
vina0631

Latest Threads

Top