Access controls in Web User Control from web form

Discussion in 'ASP .Net' started by Joachim Feldt, Nov 1, 2004.

  1. 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
     
    Joachim Feldt, Nov 1, 2004
    #1
    1. Advertising

  2. 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";

    }

    }

    "Joachim Feldt" <> wrote in message news:...
    > 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
     
    Enrique Santa Cruz, Nov 1, 2004
    #2
    1. Advertising

  3. Joachim Feldt

    Matt Berther Guest

    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";
    > }
    >
    > }
    >
    > "Joachim Feldt" <> wrote in message
    > news:...
    >
    >> 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
    >>
     
    Matt Berther, Nov 1, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mr Newbie
    Replies:
    3
    Views:
    500
    Kevin Spencer
    Oct 31, 2005
  2. =?Utf-8?B?REo=?=
    Replies:
    2
    Views:
    476
    =?Utf-8?B?REo=?=
    Dec 1, 2005
  3. Chris Zopers

    Access user control from other user control

    Chris Zopers, Feb 20, 2008, in forum: ASP .Net
    Replies:
    3
    Views:
    575
    Nanda Lella[MSFT]
    Apr 27, 2009
  4. Faizan Ahmed
    Replies:
    1
    Views:
    288
    John Saunders
    Jan 4, 2005
  5. Faizan Ahmed
    Replies:
    1
    Views:
    366
    John Saunders
    Jan 4, 2005
Loading...

Share This Page