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

D

darrel

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
 
G

Guest

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.
 
S

Scott M.

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.
 
D

darrel

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
 
D

darrel

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
 
G

Guest

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.
 
D

darrel

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
 

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