Copied to clipboard

Flag this post as spam?

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


  • Taras 30 posts 151 karma points
    Jan 29, 2014 @ 21:42
    Taras
    0

    UserControl click event doesn't work

    Current situation:

    In Umbraco website layout written with Razor syntax.

    On some pages I called UserControl like macros(set macros in RichTextBox).

    UserControl written with WebForms syntax.

    In this UserControl(in file *.ascx) is defined btn:

      <asp:LinkButton ID="btnSeries"  OnClick="btnSeries_Click"  ClientIDMode="Static" runat="server" Style="width: 322px;" Text="Series" />                   

    and in file *.ascx.cs defined handler:

    protected void btnSeries_Click(object sender, EventArgs e)
    { //something code }

    When clicking on the btn get next error in browser console panel:

    __doPostBack is not defined

     

    Can anybody give me advice how avoid this error?

    Thanks.

    some thoughts: maybe it is because there are not definition. As I know it's no possible do with Razor. Is it True? What do in this case?

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Jan 30, 2014 @ 10:41
    Jeavon Leopold
    0

    Hi Taras,

    How are you rendering your UserControl into your template?

    Also do you have the <form runat=server> around your control in the masterpage template?

    Jeavon

  • Taras 30 posts 151 karma points
    Jan 30, 2014 @ 13:37
    Taras
    0

    Hi Jeavon,

    1. How are you rendering your UserControl into your template?
    • When created macros choosed: Use in rich text editor  and Render in rich text editor. After this I added macros on the page in property which type is rich text editor.
    • In View called next: @CurrentPage.umbMmacro where umbMmacro is alias of property

          2.   Also do you have the <form runat=server> around your control in the masterpage template?

    • No, I have not. Neither     <form runat=server>  nor masterpage template.  Instead masterpage template is layout written with Razor syntax(maybe it's my  mistake).
  • Comment author was deleted

    Jan 30, 2014 @ 14:08

    Make sure you aren't running in mvc mode if you want to use usercontrols since that won't work..

  • Taras 30 posts 151 karma points
    Jan 30, 2014 @ 14:27
    Taras
    0

    Hi, Tim.

    • Make sure you aren't running in mvc mode if you want to use usercontrols since that won't work..

    How to check in which mode am I now? 

     

    some thoughts:

    Jeroen Breuer wrote:

    A UserControl in Razor will probably give you problems with postbacks and things like that. I just used a simple workaround and that's by placing an iframe in the Razor file and let the iframe point to a page which showed the UserControl.

    Maybe it is key to solution. 


  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Jan 30, 2014 @ 18:04
    Jeavon Leopold
    0

    Hi Taras,

    So you are using MVC templates/views, they would be .cshtml files?

    You can check if you are using MVC mode by looking in /config/umbracoSettings.config and looking for the defaultRenderingEngine element and seeing if it is set to Mvc or Webforms.

    Jeavon

  • Taras 30 posts 151 karma points
    Jan 30, 2014 @ 18:40
    Taras
    0
    Jeavon,
    • So you are using MVC templates/views, they would be .cshtml files?
    Yes, I am using MVC templates/views. Current mode is:
       <defaultRenderingEngine>Mvc</defaultRenderingEngine>
    Switch it and rewrite all views?
  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Jan 30, 2014 @ 18:46
    Jeavon Leopold
    100

    Hi Taras,

    Yes if you need to use UserControls with ViewState then yes, you will need to switch to WebForms rendering engine and create your templates as MasterPages. You should be able to migrate any Razor you have from your Views/Partials in Macro Partial Views which you can render in your WebForms templates.

    Jeavon

  • Taras 30 posts 151 karma points
    Jan 30, 2014 @ 19:08
    Taras
    0

    Ok, I will do it.

    Jeavon Leopold  and Tim Geyssens thanks for  the help. 

Please Sign in or register to post replies

Write your reply to:

Draft