Still confused...using an HTML Control to modify an HTML tag's value

Discussion in 'ASP .Net' started by darrel, Oct 15, 2004.

  1. darrel

    darrel Guest

    I've asked this a few times and gotten answers, but I'm still missing a
    piece of the puzzle.

    Here's what I have:

    - page.aspx
    - title tag
    - usercontrol.aspx
    - usercontrol.aspx.vb

    I'd like to change the value of the title tag from the usercontrol.aspx.vb
    codebehind.

    Some suggestions were to add a runat="server" as such:

    <title id="pageTitle" runat="server">my text</title>

    And then declare it in the codebehind. That's where I'm stuck. What do I
    declare this as?

    It was also suggested that I use a title HTML Control. However, I can't seem
    to find any reference to Title HTML controls specifically...

    -Darrel
    darrel, Oct 15, 2004
    #1
    1. Advertising

  2. RE: Still confused...using an HTML Control to modify an HTML tag's val

    In the design view of the aspx page, add a "Label" control to the page. Name
    it "TitleLabel" or something. Save the page. The code-behind for the page
    there is a declaration , probably in the "Web Form Designer Generated Code"
    section, for the label control. Move it out of the "Web Form Designer
    Generated Code" section to somewhere else near the top of the class code.
    Change the declaration to be similar to the following.
    Public Shared WithEvents TitleLabel As System.Web.UI.WebControls.Label

    You should now be able to reference it by name and change the text.

    I do something similar in a user-control that I use to house a
    page-banner-section in which I customize the label for each page at runtime.
    =?Utf-8?B?QnJhZCBSb2JlcnRz?=, Oct 15, 2004
    #2
    1. Advertising

  3. darrel

    Scott M. Guest

    Haven't tried this, but the user control's "parent" control is the page that
    you wish to modify the title of. The title is a property of the page
    itself, so if you can find a way to reference the page, you should be able
    to just adjust the .title property.


    "darrel" <> wrote in message
    news:...
    > I've asked this a few times and gotten answers, but I'm still missing a
    > piece of the puzzle.
    >
    > Here's what I have:
    >
    > - page.aspx
    > - title tag
    > - usercontrol.aspx
    > - usercontrol.aspx.vb
    >
    > I'd like to change the value of the title tag from the usercontrol.aspx.vb
    > codebehind.
    >
    > Some suggestions were to add a runat="server" as such:
    >
    > <title id="pageTitle" runat="server">my text</title>
    >
    > And then declare it in the codebehind. That's where I'm stuck. What do I
    > declare this as?
    >
    > It was also suggested that I use a title HTML Control. However, I can't
    > seem
    > to find any reference to Title HTML controls specifically...
    >
    > -Darrel
    >
    >
    Scott M., Oct 15, 2004
    #3
  4. darrel

    darrel Guest

    Re: Still confused...using an HTML Control to modify an HTML tag's val

    > In the design view of the aspx page, add a "Label" control to the page.

    Ah! Duh. OK, so I'm actually going to write out the HTML via the label.
    Seems obvious now. ;o)

    Second question...if I do this, can I declare this label in the usercontrol
    codebehind? In otherwords, the control is part of the parent page, and I
    want to manipulate it via a separate userControl on this page.

    -Darrel
    darrel, Oct 15, 2004
    #4
  5. darrel

    darrel Guest

    > Haven't tried this, but the user control's "parent" control is the page
    that
    > you wish to modify the title of. The title is a property of the page
    > itself, so if you can find a way to reference the page, you should be able
    > to just adjust the .title property.


    Right...that's my question. ;o)

    I was hoping I could do something like page.parent.title.text = "whatever"

    -Darrel
    darrel, Oct 15, 2004
    #5
  6. Re: Still confused...using an HTML Control to modify an HTML tag's

    You can put it in the user control if you want. If you want you can
    manipulate the content of the label fromn the parent page.

    "darrel" wrote:

    > > In the design view of the aspx page, add a "Label" control to the page.

    >
    > Ah! Duh. OK, so I'm actually going to write out the HTML via the label.
    > Seems obvious now. ;o)
    >
    > Second question...if I do this, can I declare this label in the usercontrol
    > codebehind? In otherwords, the control is part of the parent page, and I
    > want to manipulate it via a separate userControl on this page.
    >
    > -Darrel
    >
    >
    >
    =?Utf-8?B?QnJhZCBSb2JlcnRz?=, Oct 15, 2004
    #6
  7. darrel

    darrel Guest

    Re: Still confused...using an HTML Control to modify an HTML tag's

    > You can put it in the user control if you want. If you want you can
    > manipulate the content of the label fromn the parent page.


    I may not have asked the question very clearly.

    Can I have the Label exist on the parent.aspx page and manipulate it via the
    usercontrol.aspx.vb page?

    -Darrel
    darrel, Oct 15, 2004
    #7
    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. darrel
    Replies:
    2
    Views:
    341
    darrel
    Sep 8, 2004
  2. Replies:
    6
    Views:
    6,839
  3. shruds
    Replies:
    1
    Views:
    779
    John C. Bollinger
    Jan 27, 2006
  4. DJurgovan

    Build a control to modify attributes of the <body> tag

    DJurgovan, Nov 18, 2004, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    120
    DJurgovan
    Nov 18, 2004
  5. markbaer

    Modify Head Tag from Custom Control.

    markbaer, Aug 1, 2005, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    127
    markbaer
    Aug 1, 2005
Loading...

Share This Page