Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How to render a piece if ASP.NET code into HTML?

Reply
Thread Tools

How to render a piece if ASP.NET code into HTML?

 
 
Przemo
Guest
Posts: n/a
 
      07-18-2004
Hi,

In classic ASP I was able to do something like:
<title><%=MyVariableWithTitle%></title>

How to do the same in ASP.NET using VB.NET?

thank you!

Przemo
 
Reply With Quote
 
 
 
 
Teemu Keiski
Guest
Posts: n/a
 
      07-18-2004
Hi,

for example put Literal control on the header between <title> tags and set
its Text property to the text you want to display in the title. Another
alternative is just to put the <title> tag with an ID and runat="server"
attributes and then set innerHtml/innerText property programmatically.
Result is the same

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
http://blogs.aspadvice.com/joteke


"Przemo" <> wrote in message
news:2f85801c46ccf$985f29a0$...
> Hi,
>
> In classic ASP I was able to do something like:
> <title><%=MyVariableWithTitle%></title>
>
> How to do the same in ASP.NET using VB.NET?
>
> thank you!
>
> Przemo



 
Reply With Quote
 
 
 
 
Ken Cox [Microsoft MVP]
Guest
Posts: n/a
 
      07-18-2004
Here's one way...

<%@ Page Language="vb" AutoEventWireup="True" %>
<script language=vb runat=server>
public MyVariableWithTitle as string
Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
MyVariableWithTitle = "Page Title"
End Sub
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title><%= MyVariableWithTitle%></title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
Hi Przemo
</form>
</body>
</HTML>

Does this help?

Ken
Microsoft MVP [ASP.NET]
Toronto

"Przemo" <> wrote in message
news:2f85801c46ccf$985f29a0$...
> Hi,
>
> In classic ASP I was able to do something like:
> <title><%=MyVariableWithTitle%></title>
>
> How to do the same in ASP.NET using VB.NET?
>
> thank you!
>
> Przemo


 
Reply With Quote
 
Guest
Posts: n/a
 
      07-18-2004
Thank you!
I wanted to use your idea for another case, but it
doesn't work.
In this case I would like to insert value determining
time of timeout.

<SCRIPT LANGUAGE="JavaScript">
<!--
function refresh_window() {
setTimeout
('window.location.href="SamochodyCzekajace.aspx"',
<asp:Literal id="Literal1" runat="server"></asp:Literal>);
}
//-->
</SCRIPT>

Przemo

>-----Original Message-----
>Hi,
>
>for example put Literal control on the header between

<title> tags and set
>its Text property to the text you want to display in the

title. Another
>alternative is just to put the <title> tag with an ID

and runat="server"
>attributes and then set innerHtml/innerText property

programmatically.
>Result is the same
>
>--
>Teemu Keiski
>MCP, Microsoft MVP (ASP.NET), AspInsiders member
>ASP.NET Forum Moderator, AspAlliance Columnist
>http://blogs.aspadvice.com/joteke
>
>
>"Przemo" <> wrote in message
>news:2f85801c46ccf$985f29a0$...
>> Hi,
>>
>> In classic ASP I was able to do something like:
>> <title><%=MyVariableWithTitle%></title>
>>
>> How to do the same in ASP.NET using VB.NET?
>>
>> thank you!
>>
>> Przemo

>
>
>.
>

 
Reply With Quote
 
Guest
Posts: n/a
 
      07-18-2004
Yes it helped!
It is so trival...
But I have another similar problrm, with programatic
inserting some value into html as a part of JavaScript.
I have sent example for this newsgroup few minutes
earlier as a replay for my first post.

Przemo
>-----Original Message-----
>Here's one way...
>
><%@ Page Language="vb" AutoEventWireup="True" %>
><script language=vb runat=server>
>public MyVariableWithTitle as string
> Private Sub Page_Load _
> (ByVal sender As System.Object, _
> ByVal e As System.EventArgs) _
> Handles MyBase.Load
> MyVariableWithTitle = "Page Title"
>End Sub
></script>
><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0

Transitional//EN">
><HTML>
> <HEAD>
> <title><%= MyVariableWithTitle%></title>
> <meta name="GENERATOR" content="Microsoft Visual

Studio .NET 7.1">
> <meta name="CODE_LANGUAGE" content="Visual Basic .NET

7.1">
> <meta name="vs_defaultClientScript"

content="JavaScript">
> <meta name="vs_targetSchema"
>content="http://schemas.microsoft.com/intellisense/ie5">
> </HEAD>
> <body>
> <form id="Form1" method="post" runat="server">
> Hi Przemo
> </form>
> </body>
></HTML>
>
>Does this help?
>
>Ken
>Microsoft MVP [ASP.NET]
>Toronto
>
>"Przemo" <> wrote in message
>news:2f85801c46ccf$985f29a0$...
>> Hi,
>>
>> In classic ASP I was able to do something like:
>> <title><%=MyVariableWithTitle%></title>
>>
>> How to do the same in ASP.NET using VB.NET?
>>
>> thank you!
>>
>> Przemo

>
>.
>

 
Reply With Quote
 
Teemu Keiski
Guest
Posts: n/a
 
      07-18-2004
Make it another way. Create a Literal to which output the complete script or
optionally use Page.RegisterClientScriptBlock and or
Page.RegisterStartupScript methods for registering scripts.

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
http://blogs.aspadvice.com/joteke




<> wrote in message
news:2f29d01c46ce7$3376b7c0$...
> Thank you!
> I wanted to use your idea for another case, but it
> doesn't work.
> In this case I would like to insert value determining
> time of timeout.
>
> <SCRIPT LANGUAGE="JavaScript">
> <!--
> function refresh_window() {
> setTimeout
> ('window.location.href="SamochodyCzekajace.aspx"',
> <asp:Literal id="Literal1" runat="server"></asp:Literal>);
> }
> //-->
> </SCRIPT>
>
> Przemo
>
> >-----Original Message-----
> >Hi,
> >
> >for example put Literal control on the header between

> <title> tags and set
> >its Text property to the text you want to display in the

> title. Another
> >alternative is just to put the <title> tag with an ID

> and runat="server"
> >attributes and then set innerHtml/innerText property

> programmatically.
> >Result is the same
> >
> >--
> >Teemu Keiski
> >MCP, Microsoft MVP (ASP.NET), AspInsiders member
> >ASP.NET Forum Moderator, AspAlliance Columnist
> >http://blogs.aspadvice.com/joteke
> >
> >
> >"Przemo" <> wrote in message
> >news:2f85801c46ccf$985f29a0$...
> >> Hi,
> >>
> >> In classic ASP I was able to do something like:
> >> <title><%=MyVariableWithTitle%></title>
> >>
> >> How to do the same in ASP.NET using VB.NET?
> >>
> >> thank you!
> >>
> >> Przemo

> >
> >
> >.
> >



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Download a file piece by piece Patrick Plattes Ruby 2 11-30-2006 07:48 PM
Accessing rails render method outside of view / Decorating render Glenn Gillen Ruby 0 11-17-2006 02:30 PM
Question on optimizing a piece of code =?Utf-8?B?RGlmZmlkZW50?= ASP .Net 3 06-09-2005 05:17 PM
Page.Render do not render complete page Lau Lei Cheong ASP .Net 1 05-15-2004 04:10 AM
highlight the piece of code executed Hristo Stevic Java 0 12-07-2003 08:35 PM



Advertisments