Access controls in Web User Control from web form

J

Joachim Feldt

Hi,

I am a newbie, so some help here would be very appreciated!

I have a aspx-page with four links at the top of the page. These links
are the application navigation and they are stored in a separate Web
User Control(ctrlTop.ascx).
These four links are added as asp:Hyperlink, with an ImageUrl set as
well. So the links are displayed as images.

When browsing my application I want to show the user in what section
he/she is by highlighting that image(hyperlink) in the navigation on
the top(my Web User Control).
To do this I want to change the ImageUrl on that hyperlink to another
image.

So in other words, when loading an aspx page I want to change an
ImageUrl on a control in a Web User Control.

How do I do that?

And once again, I am a beginner, so if you have a code exampel please
show it here.

Thanks in advance!

/Jocke
 
E

Enrique Santa Cruz

protected System.Web.UI.WebControls.HyperLink HyperLink;

private void Header_Load(object sender, System.EventArgs e)

{

if(Page.IsPostBack != true)

{

HyperLink.ImageUrl = Application["ApplicationPath"]+"images/tm_triad.gif";

}

}
 
M

Matt Berther

Hello Enrique,

Why would you store this in an Application level variable? This supposes
that you want the triad.gif to show on the same link for every user in the
entire application.

Perhaps a better spot would be Session, as it is user-specific...

--
Matt Berther
http://www.mattberther.com
protected System.Web.UI.WebControls.HyperLink HyperLink;

private void Header Load(object sender, System.EventArgs e)

{

if(Page.IsPostBack != true)

{

HyperLink.ImageUrl =
Application["ApplicationPath"]+"images/tm triad.gif";
}

}

Hi,

I am a newbie, so some help here would be very appreciated!

I have a aspx-page with four links at the top of the page. These
links
are the application navigation and they are stored in a separate Web
User Control(ctrlTop.ascx).
These four links are added as asp:Hyperlink, with an ImageUrl set as
well. So the links are displayed as images.
When browsing my application I want to show the user in what section
he/she is by highlighting that image(hyperlink) in the navigation on
the top(my Web User Control).
To do this I want to change the ImageUrl on that hyperlink to another
image.
So in other words, when loading an aspx page I want to change an
ImageUrl on a control in a Web User Control.

How do I do that?

And once again, I am a beginner, so if you have a code exampel please
show it here.

Thanks in advance!

/Jocke
 

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,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top