1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to create Dynamic Title

Discussion in 'C#' started by checkcost, Aug 16, 2007.

  1. #1
    Hi,

    I want to change the title of a website http://checkcost.co.uk/ dynamically. It's an ecommerce website. Suppose we have a product " Sony Vaio laptop" , I want when some one browse the landing page of sony vaio laptop, the title of the page should show sony vaio laptop.

    please give me solution as details as possible with reference script & links.


    Thanks!
     
    checkcost, Aug 16, 2007 IP
  2. mjamesb

    mjamesb Member

    Messages:
    88
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    48
    #2
    The only way I can see that you can do it is to grab the urlreferrer and parse the query string...if you find certain keywords you could change the title

    Request.UrlReferrer
     
    mjamesb, Aug 25, 2007 IP
  3. AndyFarrell

    AndyFarrell Peon

    Messages:
    89
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    if you`re using asp.net 2.0
    you can use virtual path provider and build the page on the fly.
     
    AndyFarrell, Aug 27, 2007 IP
  4. AstarothSolutions

    AstarothSolutions Peon

    Messages:
    2,680
    Likes Received:
    77
    Best Answers:
    0
    Trophy Points:
    0
    #4
    page.title sets the page title so just grab the words to include from the url/ querystrings/ database and either set the page title or if using master files to set the base just have page.title &= to append the extra to the end of the title.

    Meta is slightly more difficult but not much
     
    AstarothSolutions, Aug 30, 2007 IP
  5. suraj_ajax

    suraj_ajax Peon

    Messages:
    26
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    as said earlier luk of out for referring page query string ...

    For Google
    THE referring url will be : google.co.in/search?q=sony+vaio&sourceid=navclient-ff&ie=UTF-8&rlz=1B3GGGL_enIN176IN231

    So just extract the value of "q" ...thats it

    Althought i haven't tried.. but it shud work ..

    All the best and do post the result
     
    suraj_ajax, Sep 11, 2007 IP
  6. adrevol

    adrevol Active Member

    Messages:
    124
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    58
    #7
    Try to pass what ever keyword u want to url query string ,
    then in the title tag simply embed the querystring value with asp tags like

    <title><%=Request.Querystring("key")%> -- Your Site Name </title>
    Code (markup):
    this will put your sony vio lap tops before your site name
     
    adrevol, Sep 15, 2007 IP
    seolion likes this.
  7. fluid

    fluid Active Member

    Messages:
    679
    Likes Received:
    29
    Best Answers:
    0
    Trophy Points:
    70
    #8
    Easy!

    You already know what the title is going to be because you have the product in your inventory. So set Page.Title = MyProductTitle just like AstarothSolutions suggested.
     
    fluid, Sep 17, 2007 IP
  8. turksweb

    turksweb Peon

    Messages:
    354
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #9
    just get the title from db / products name, easy thing..
     
    turksweb, Feb 18, 2008 IP
  9. AstarothSolutions

    AstarothSolutions Peon

    Messages:
    2,680
    Likes Received:
    77
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Would have thought the user had worked this out a few months ago.

    Really shouldnt use <%=Request.Querystring("key")%> as this just leaves your site open to abuse unless you want to have people create a link like http://www.YourSite.com/default.asp?key=Hard+Core+Porn and google then indexes the page with the title of Hard Core Porn.

    Any user input should be cleansed/ validated first before displaying
     
    AstarothSolutions, Feb 19, 2008 IP
  10. yugolancer

    yugolancer Well-Known Member

    Messages:
    320
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    110
    #11
    I agree with AstarothSolutions. It is not the best approach.
     
    yugolancer, Mar 14, 2008 IP
  11. coolcode007

    coolcode007 Well-Known Member

    Messages:
    1,122
    Likes Received:
    22
    Best Answers:
    0
    Trophy Points:
    148
    #12
    here is the code i use to create dynamic titles (C#.Net in Visual Studio 2005)

    
            HtmlTitle ht = new HtmlTitle();
            HtmlHead head = (HtmlHead)Page.Header;
            ht.Text = "My Title Goes Here, so put the title dynamically";
            head.Controls.Add(ht);
    
    Code (markup):
    make sure you dont have a <title> </title> tag in the header section

    
    <head runat="server">
    </head>
    
    Code (markup):
     
    coolcode007, Mar 18, 2008 IP
  12. AndyFarrell

    AndyFarrell Peon

    Messages:
    89
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #13
    this is what i use in .net
    Page.Title = "Title of Page";
    for Dynamic meta tags/ keywords i use coolcode007`s option, something like this

    public static void SEO(Page thisPage ,string title, string keywords, string discription)
        {
            HtmlHead header = (HtmlHead)thisPage.Header;
            HtmlMeta Dmeta = new HtmlMeta();
            Dmeta.Name = "Description";
            Dmeta.Content = discription;
            header.Controls.Add(Dmeta);
    
            HtmlMeta Kmeta = new HtmlMeta();
            Kmeta.Name = "Keywords";
            Kmeta.Content = keywords;
            header.Controls.Add(Kmeta);
    
            HtmlMeta Tmeta = new HtmlMeta();
            Tmeta.Name = "Title";
            Tmeta.Content = title;
            header.Controls.Add(Tmeta);
    
        }
    Code (markup):
     
    AndyFarrell, Mar 18, 2008 IP
    Yankee85 likes this.
  13. Yankee85

    Yankee85 Peon

    Messages:
    1,067
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #14
    Thanks AndyFarrell!
     
    Yankee85, Apr 25, 2008 IP