switching between HTML and ASPNET

G

Guest

Hi

I want to write de content of a variable from my asp net code into the Title
Bar of the Browser

each time I need to switch between those world (HTML-ASPNET) I suffer cause
I don’t have clear the boundaries in between

What alternatives do I have?
Where Can I find a good documentation about using or switching between HTML
and ASPNET, passing data, controlling html controls. etc

Thks
 
G

Guest

If you set runat="server" in any HTML tag you can set it's properties in
server side code referencing it by ID. However you can do what you need to
do simply using the following in the Page_load event handler.

string PageTitle = "My Page";
Page.Title = PageTitle;
 
G

Guest

Hi

Thanks for your answer but the first thing I did was looking for Title
property and there is not such property in the Page object, at lease I can
not find it..

I'm working in VB.NET

also I know that I can convert HTML controls to server controls, but how do
you manage sections like <HEAD><TITLE>?.


thks
 
G

Guest

I started with ASP.net 2.0 in which the page object has a title property,
maybe it doesn't in 1.1

To handle any HTML tag simply set runat="server" and give it an ID, then you
can set it's properties programatically via server side code.

e.g.

<head runat="server" id="myHead">

You can then set the title with MyHead.Title = "MyTitle";

As i say i have never used asp.net 1.1 so if this doesn't work for you maybe
it's time to upgrade.
 
G

Guest

Ok that works

I’m still looking for ways to work more directly between ASPNET and HTML
without convert, I remember something like <@# > to include asp controls
into the HTML etc, but I can find a tutorial so if you have one pass it to me.

I can not migrate because the company does not want to do it yet :/ anyway
thks.
 
G

Guest

Putting code within the HTML is the old, bad, classic ASP way of doing
things. ASP.net is object and event driven. So in short, apart from a
couple of exceptions such as binding things to controls in TemplateFields,
you do not do things the way you are suggesting, ASP.net it is simply not
designed that way. This is a good thing. The ASP.net way of doing things is
much better, and leads to much easier to understand, cleaner and more stable
code, that is much much easier to maintain in the long run.
 
G

Guest

Definitely you are right , some time I forget the philosophy of ASP.NET

thks

anyway talking about the same issue, when you set the runat and id words in
htmlcontrols those controls are recognized in .net code windows but for items
like HTML , TITLE or HEAD even you can set perfectly the attributes ASP1.1
does not recognized those elements in code.
 
M

Mark Rae

anyway talking about the same issue, when you set the runat and id words
in
htmlcontrols those controls are recognized in .net code windows but for
items
like HTML , TITLE or HEAD even you can set perfectly the attributes
ASP1.1
does not recognized those elements in code.

On your ASPX page...

<html>
<head>
<title><asp:Label ID=lblTitle Runat=server /></title>
</head>

<body>

</body>
</html>

On your class page...

protected Label lblTitle;

lblTitle.Text = "This is my page title";
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top