Access controls in Web User Control from web form

  • Thread starter Thread starter Joachim Feldt
  • Start date Start date
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
 
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";

}

}
 
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
 
Back
Top