title section dynamically

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dariusz Tomon

    title section dynamically

    Hi

    Is it possible to change dynamically <title></title> section in page. What I
    want is to have <title> section depended on values retrieved from database.
    The question could be extended to other sections from <HEAD> section.
    If it's possible please provide an example (ideally in C#).

    Best Regards

    Darek


  • Göran Andersson

    #2
    Re: title section dynamically

    In ASP.NET 2.0 you can use Page.Title to set the title of the page. In
    ASP.NET 1.1 you can put a Literal control in the title tag.

    Dariusz Tomon wrote:[color=blue]
    > Hi
    >
    > Is it possible to change dynamically <title></title> section in page. What I
    > want is to have <title> section depended on values retrieved from database.
    > The question could be extended to other sections from <HEAD> section.
    > If it's possible please provide an example (ideally in C#).
    >
    > Best Regards
    >
    > Darek[/color]

    Comment

    • Swanand Mokashi

      #3
      Re: title section dynamically

      If you are using Master pages with ASP.NET 2.0 you can see the power of ~
      here :


      --
      Swanand Mokashi
      Microsoft Certified Solution Developer (.NET) - Early Achiever
      Microsoft Certified Application Developer (.NET)


      DotNetGenerics. com -- anything and everything about Microsoft .NET
      technology ...

      Welcome to our website ! Well, our domain name introduces you to one half of us. The other (and perhaps better ;)) half is Rashmi Upasani. Rashmi dwells from


      Home of the Stock Quotes, Quote of the day and Horoscope web services


      "Göran Andersson" <guffa@guffa.co m> wrote in message
      news:O1CiAYDcGH A.4224@TK2MSFTN GP04.phx.gbl...[color=blue]
      > In ASP.NET 2.0 you can use Page.Title to set the title of the page. In
      > ASP.NET 1.1 you can put a Literal control in the title tag.
      >
      > Dariusz Tomon wrote:[color=green]
      >> Hi
      >>
      >> Is it possible to change dynamically <title></title> section in page.
      >> What I want is to have <title> section depended on values retrieved from
      >> database. The question could be extended to other sections from <HEAD>
      >> section.
      >> If it's possible please provide an example (ideally in C#).
      >>
      >> Best Regards
      >>
      >> Darek[/color][/color]


      Comment

      • Dariusz Tomon

        #4
        Re: title section dynamically

        unfortunatelly I'm using ASP.NET 1.1 so could you provide an example?

        Best Regards

        Darek T.

        "Göran Andersson" <guffa@guffa.co m> wrote in message
        news:O1CiAYDcGH A.4224@TK2MSFTN GP04.phx.gbl...[color=blue]
        > In ASP.NET 2.0 you can use Page.Title to set the title of the page. In
        > ASP.NET 1.1 you can put a Literal control in the title tag.
        >
        > Dariusz Tomon wrote:[color=green]
        >> Hi
        >>
        >> Is it possible to change dynamically <title></title> section in page.
        >> What I want is to have <title> section depended on values retrieved from
        >> database. The question could be extended to other sections from <HEAD>
        >> section.
        >> If it's possible please provide an example (ideally in C#).
        >>
        >> Best Regards
        >>
        >> Darek[/color][/color]


        Comment

        • Göran Andersson

          #5
          Re: title section dynamically

          <title><asp:Lit eral id="asdf" runat="server"/></title>

          asdf.Text = "First page";

          Dariusz Tomon wrote:[color=blue]
          > unfortunatelly I'm using ASP.NET 1.1 so could you provide an example?
          >
          > Best Regards
          >
          > Darek T.
          >
          > "Göran Andersson" <guffa@guffa.co m> wrote in message
          > news:O1CiAYDcGH A.4224@TK2MSFTN GP04.phx.gbl...[color=green]
          >> In ASP.NET 2.0 you can use Page.Title to set the title of the page. In
          >> ASP.NET 1.1 you can put a Literal control in the title tag.
          >>
          >> Dariusz Tomon wrote:[color=darkred]
          >>> Hi
          >>>
          >>> Is it possible to change dynamically <title></title> section in page.
          >>> What I want is to have <title> section depended on values retrieved from
          >>> database. The question could be extended to other sections from <HEAD>
          >>> section.
          >>> If it's possible please provide an example (ideally in C#).
          >>>
          >>> Best Regards
          >>>
          >>> Darek[/color][/color]
          >
          >[/color]

          Comment

          • Dariusz Tomon

            #6
            Re: title section dynamically

            ok - it works - thank you

            "Göran Andersson" <guffa@guffa.co m> wrote in message
            news:OHJqKlVcGH A.5016@TK2MSFTN GP04.phx.gbl...[color=blue]
            > <title><asp:Lit eral id="asdf" runat="server"/></title>
            >
            > asdf.Text = "First page";
            >
            > Dariusz Tomon wrote:[color=green]
            >> unfortunatelly I'm using ASP.NET 1.1 so could you provide an example?
            >>
            >> Best Regards
            >>
            >> Darek T.
            >>
            >> "Göran Andersson" <guffa@guffa.co m> wrote in message
            >> news:O1CiAYDcGH A.4224@TK2MSFTN GP04.phx.gbl...[color=darkred]
            >>> In ASP.NET 2.0 you can use Page.Title to set the title of the page. In
            >>> ASP.NET 1.1 you can put a Literal control in the title tag.
            >>>
            >>> Dariusz Tomon wrote:
            >>>> Hi
            >>>>
            >>>> Is it possible to change dynamically <title></title> section in page.
            >>>> What I want is to have <title> section depended on values retrieved
            >>>> from database. The question could be extended to other sections from
            >>>> <HEAD> section.
            >>>> If it's possible please provide an example (ideally in C#).
            >>>>
            >>>> Best Regards
            >>>>
            >>>> Darek[/color]
            >>[/color][/color]

            Comment

            • Laurent Bugnion, GalaSoft

              #7
              Re: title section dynamically

              Hi,

              Göran Andersson wrote:[color=blue]
              > <title><asp:Lit eral id="asdf" runat="server"/></title>
              >
              > asdf.Text = "First page";[/color]

              I prefer this way:

              <title runat="server" id="pageTitle"> Default title</title>

              and then:

              HtmlGenericCont rol windowTitle
              = FindControl( "title" ) as HtmlGenericCont rol;

              if( windowTitle == null )
              throw new ApplicationExce ption( "..." );

              windowTitle.Inn erHtml = "My title";

              HTH
              Laurent
              --
              Laurent Bugnion, GalaSoft
              Software engineering: http://www.galasoft-LB.ch
              Private/Malaysia: http://mypage.bluewin.ch/lbugnion
              Support children in Calcutta: http://www.calcutta-espoir.ch

              Comment

              • Göran Andersson

                #8
                Re: title section dynamically

                Laurent Bugnion, GalaSoft wrote:[color=blue]
                > Hi,
                >
                > Göran Andersson wrote:[color=green]
                >> <title><asp:Lit eral id="asdf" runat="server"/></title>
                >>
                >> asdf.Text = "First page";[/color]
                >
                > I prefer this way:
                >
                > <title runat="server" id="pageTitle"> Default title</title>
                >
                > and then:
                >
                > HtmlGenericCont rol windowTitle
                > = FindControl( "title" ) as HtmlGenericCont rol;
                >
                > if( windowTitle == null )
                > throw new ApplicationExce ption( "..." );
                >
                > windowTitle.Inn erHtml = "My title";
                >
                > HTH
                > Laurent[/color]

                Doesn't the FindControl use the id rather than the tag name?

                Why use FindControl ayway when you can reference the control directly?

                Comment

                • Laurent Bugnion

                  #9
                  Re: title section dynamically

                  Hi,

                  Göran Andersson wrote:[color=blue]
                  > Laurent Bugnion, GalaSoft wrote:
                  >[color=green]
                  >> <title runat="server" id="pageTitle"> Default title</title>
                  >>
                  >> and then:
                  >>
                  >> HtmlGenericCont rol windowTitle
                  >> = FindControl( "title" ) as HtmlGenericCont rol;
                  >>
                  >> if( windowTitle == null )
                  >> throw new ApplicationExce ption( "..." );
                  >>
                  >> windowTitle.Inn erHtml = "My title";[/color]
                  >
                  > Doesn't the FindControl use the id rather than the tag name?[/color]

                  Sorry, it was a typo. This should read

                  HtmlGenericCont rol windowTitle
                  = FindControl( "pageTitle" ) as HtmlGenericCont rol;
                  [color=blue]
                  > Why use FindControl ayway when you can reference the control directly?[/color]

                  That's correct.

                  Laurent
                  --
                  Laurent Bugnion, GalaSoft
                  Software engineering: http://www.galasoft-LB.ch
                  Private/Malaysia: http://mypage.bluewin.ch/lbugnion
                  Support children in Calcutta: http://www.calcutta-espoir.ch

                  Comment

                  Working...