Copied to clipboard

Flag this post as spam?

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


  • Jesper Lysgaard 16 posts 76 karma points
    Nov 04, 2009 @ 09:56
    Jesper Lysgaard
    0

    Codebehind on masterpages - is it possible in umbraco 4.0?

    Hi,

    I am a week or so into Umbraco and has only scratched the surface.

    My current project is to move a small site from Ektron cms400 to Umbraco 4. I'm almost there but ran into this in getting the site compatible with Safari.

    On the old site I was using this in codebehind on my masterpages to get the asp:menu control to work right in Safari:

    protected override void AddedControl(Control control, int index)

    {

     

    if (Request.ServerVariables["http_user_agent"].IndexOf("Safari", StringComparison.CurrentCultureIgnoreCase) != -1)

     

    this.Page.ClientTarget = "uplevel";

     

    base.AddedControl(control, index);

    }

    But I guess the model in umbraco is different? Is it possible to add a masterpage the 'normal' way with codebehind?

    Thanks
    /Jesper

  • Rasmus Berntsen 215 posts 253 karma points c-trib
    Nov 04, 2009 @ 09:59
    Rasmus Berntsen
    1

    Yes, just create the template (Masterpage) from Visual Studio. That way you'll have your codebehind etc. You'll have to create a template in umbraco with the same filename before it's visible. That's the way I usually do it.

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Nov 04, 2009 @ 11:02
    Aaron Powell
    0

    You don't have to create it in Visual Studio, you just need to make sure you set the Inherits statement see the MSDN overview for Master Pages - http://msdn.microsoft.com/en-us/library/wtxbf3hh.aspx

  • Petr Snobelt 923 posts 1535 karma points
    Nov 04, 2009 @ 11:19
    Petr Snobelt
    0

    You don't need codebehind, you can add <script runat="server"> directly to masterpage, but in this particular case there is better way - add browser file, using google I found this, maybe it is not 100% correct, but it's a right way:

     What I did to enable the asp:menu for Safari was to add a file called safari.browser to the App_Browsers folder. The contents of safari.browser are as follows: 

    <browsers>
      <browser refID="safari1plus">
        <controlAdapters>
          <adapter controlType="System.Web.UI.WebControls.Menu" adapterType="" />
        </controlAdapters>
      </browser>
    </browsers>

  • Jesper Lysgaard 16 posts 76 karma points
    Nov 04, 2009 @ 12:29
    Jesper Lysgaard
    0

    Thank you all for the responses.

    I went for the VS solution and the menu is now working in Safari as well.

    @petr
    I could not get the safari.browser solution to work - I got to look into this a little more.

    /Jesper

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies