Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Markus Pfaffinger 2 posts 22 karma points
    May 11, 2010 @ 22:53
    Markus Pfaffinger
    0

    access/change title/meta tags through custom control

    Hello,

    is there any possibility to change the head tags items through a custom control? We use umbraco 4.0.3 and our own custom control to show things from database. Now I wanted to dynamically set the title tag and meta tags to do some SEO! I added runat=server to the head tag and also ids for the different head items, like title etc, but the content is always overwritten by Umbraco!

    I search the forum and the net, but I can't figure out the right solution. Maybe I searched for the wrong things!

     

    Thanks in advanced for all answers and the good work you do in the forum!

     

    Greets Markus

  • Chris Dunn 210 posts 401 karma points
    May 12, 2010 @ 00:30
    Chris Dunn
    0

    Welcome to the forums :)

    In your head tag  add a your normal meta tags with an id and runat='server'.

    <head runat="server">
    <title></title>
    <meta id="keywords" name="keywords" runat="server" />
    </head>

     

    In the codebehind of the the usercontrol:

    Page.Title = "My Page Title";
    ((HtmlMeta)Page.Master.FindControl("keywords")).Content = "KEYWORDS";

     

     

    -Chris

  • Markus Pfaffinger 2 posts 22 karma points
    May 12, 2010 @ 10:12
    Markus Pfaffinger
    0

    Thanks for the quick response Chris, but your solution don't work! Nothing is changed in the head, no title and no meta tags.

    My control is no usercontrol! I use a custom server control with only an assembly file (.dll) in the bin folder and no .ascx file! I think the problem is the way umbraco or asp.net integrates the control in the page. Correct me if I'm wrong.

    Maybe I have to change to an usercontrol to do the things, because this functions as you described!

     

    Markus

     

     

     

     

     

Please Sign in or register to post replies

Write your reply to:

Draft