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).
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.
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.
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.
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:
and in file *.ascx.cs defined handler:
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?
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
Hi Jeavon,
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?<form runat=server>
nor masterpage template. Instead masterpage template is layout written with Razor syntax(maybe it's my mistake).Comment author was deleted
Make sure you aren't running in mvc mode if you want to use usercontrols since that won't work..
Hi, Tim.
How to check in which mode am I now?
some thoughts:
Jeroen Breuer wrote:
Maybe it is key to solution.
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
<defaultRenderingEngine>Mvc</defaultRenderingEngine>
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
Ok, I will do it.
Jeavon Leopold and Tim Geyssens thanks for the help.
is working on a reply...