Copied to clipboard

Flag this post as spam?

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


  • MuirisOG 382 posts 1284 karma points
    Jul 05, 2017 @ 17:53
    MuirisOG
    0

    page events (e.g. page_load) are being fired twice

    Hi everyone

    I'm on webforms trying to get a site live using v7.5.14, and up until recently was building on v7.5.2 where everything was working fine.

    Our template/masterpage outputs a doctype property which holds a macro, which in turn points to a usercontrol.

    However, in v7.5.14, the page events (e.g. page_load) in the usercontrol are being fired twice.

    I took the usercontrol and put it directly into the template, and it works as expected.

    It looks as if there may be something in <umbraco:item field="myField" runat="server" /> causing this.

    Any help is appreciated.

    Thanks

    Muiris

  • MuirisOG 382 posts 1284 karma points
    Jul 06, 2017 @ 11:12
    MuirisOG
    0

    Ok, so maybe I need to reinstall this version. Is that ok to do?

    Is it ok to just reinstall Umbraco, and then point it at my original database?

  • Yakov Lebski 594 posts 2350 karma points
    Jul 06, 2017 @ 11:41
    Yakov Lebski
    0

    Maybe it's wrong direction, but check that you have no images with empty source

    <img src="" /> 
    <img src="#" /> 
    
  • MuirisOG 382 posts 1284 karma points
    Jul 07, 2017 @ 12:19
    MuirisOG
    0

    Thanks Yakov

    the problem occurred in the template, where I have to choose between two RTE fields in the same doctype, and both fields have a usercontrol, which both seem to fire!

    Re-coding the template if statement now!

    Thanks,

    Muiris

    PS: ...and this does happen in v.7.5.2

    PS: here's the duff code (DON'T do it this way!):

    <% if (Session["lang"].ToString().ToLower() == "cy-gb") { %>
      <umbraco:Item field="cy_gb_main" runat="server" />
    <% } %>
    <% else { %>
      <umbraco:Item field="en_gb_main" runat="server" />
    <% } %>
    
  • MuirisOG 382 posts 1284 karma points
    Jul 10, 2017 @ 11:53
    MuirisOG
    100

    Right, everyone,

    here's the solution that seems to work, for the particular problem I was having above.

    I replaced the duff code in my page template (a masterpage whose MasterPageFile is ~/umbraco/masterpages/default.master) above with

    <umbraco:Item field="<%$ Resources:LocalizedText, main %>" runat="server" />
    

    I have a .NET usercontrol in the page template which sets the Culture and UICulture (and in VB.NET, you have to do this in the following code block in the code behind):

    Protected Overrides Sub FrameworkInitialize()
        ... 
             'do some stuff to get the language setting from the session variable or the querystring 
             ' ... and finally, set the culture 
            Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(Culture)
            Thread.CurrentThread.CurrentUICulture = New CultureInfo(Culture)
            MyBase.FrameworkInitialize()
    End Sub
    

    I have created Resource files (a default file, one for English and one for Welsh) in App_GlobalResources, which have a setting for the field I want to output (viz main in the Umbraco:Item code above).

    I think that's it.

    However, if anyone out there sees a glaringly obvious hole in this code, please let me know as I would very much appreciate some feedback.

    Many thanks

    Muiris

  • 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