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

Discussion in 'ASP .Net' started by Przemo, Jul 18, 2004.

  1. Przemo

    Przemo Guest

    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
    Przemo, Jul 18, 2004
    #1
    1. Advertising

  2. Przemo

    Teemu Keiski Guest

    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
    Teemu Keiski, Jul 18, 2004
    #2
    1. Advertising

  3. 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
    Ken Cox [Microsoft MVP], Jul 18, 2004
    #3
  4. Przemo

    Guest Guest

    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

    >
    >
    >.
    >
    Guest, Jul 18, 2004
    #4
  5. Przemo

    Guest Guest

    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

    >
    >.
    >
    Guest, Jul 18, 2004
    #5
  6. Przemo

    Teemu Keiski Guest

    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

    > >
    > >
    > >.
    > >
    Teemu Keiski, Jul 18, 2004
    #6
    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. Samuel Lee
    Replies:
    1
    Views:
    631
    Benjie Fallar
    Jul 25, 2003
  2. Lau Lei Cheong

    Page.Render do not render complete page

    Lau Lei Cheong, May 15, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    2,047
    Lau Lei Cheong
    May 15, 2004
  3. =?Utf-8?B?RWFybCBUZWlncm9i?=

    Getting "To Render" HTML from WebControl into String

    =?Utf-8?B?RWFybCBUZWlncm9i?=, Oct 22, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    3,776
    Matt Berther
    Oct 22, 2004
  4. Glenn Gillen
    Replies:
    0
    Views:
    262
    Glenn Gillen
    Nov 17, 2006
  5. Patrick Plattes

    Download a file piece by piece

    Patrick Plattes, Nov 30, 2006, in forum: Ruby
    Replies:
    2
    Views:
    193
    Patrick Plattes
    Nov 30, 2006
Loading...

Share This Page