Button not Firing when used in UserControl Displayed with Razor
Hi,
I'm fairly new to Umbraco, so just trying a few things out at the moment. Basically we've got a one-to-one multi language website that uses a Razor shorthand "If" to display the appropriate content depending on what langauage is stored in the Session i.e.
Within mainContent, I've created a simple macro that uses a usercontrol with a solitary asp.net label and a button. When the button its clicked, the label updates to show the current time.
Using this technique above, the right content with the usercontrol is displayed as expected. However when I click the button, PostBack is not firing, the page just seems to reload.
However, if I explicitly include the mainContent content, everything looks the same but the button DOES fire as expected i.e.
Thanks for your reply. I'm using umbraco v 4.11.3. How can I tell if the rendering engine is set to use MVC? I've only started recently with Umbraco so it's all fairly new to me.
Ok then I guess you're not using MVC rendering mode.
But you can check it in the umbracoSettings.config file in the config folder. In here there are a lot of different settings. The one you should look for in this case is <defaultRenderingEngine>webforms</defaultRenderingEngine> - In your case it probably just looks like this, which is fine.
It's just that if it was set to MVC that would probably be the reason why your user control did not work when posting.
Would it be possible for you to try and refactor the Razor calling your user control to use a XSLT macro instead? Must admit that I can't remember if there can be some issues with posting a user control when it's rendered from Razor.
Button not Firing when used in UserControl Displayed with Razor
Hi,
I'm fairly new to Umbraco, so just trying a few things out at the moment. Basically we've got a one-to-one multi language website that uses a Razor shorthand "If" to display the appropriate content depending on what langauage is stored in the Session i.e.
<umbraco:Macro ID="Macro4" runat="server" language="cshtml">
@((Session["lang"].ToString() == "cy") ? @Model.mainContent_cy : @Model.mainContent)
Within mainContent, I've created a simple macro that uses a usercontrol with a solitary asp.net label and a button. When the button its clicked, the label updates to show the current time.
Using this technique above, the right content with the usercontrol is displayed as expected. However when I click the button, PostBack is not firing, the page just seems to reload.
However, if I explicitly include the mainContent content, everything looks the same but the button DOES fire as expected i.e.
<umbraco:Item ID="Item5" runat="server" field="mainContent" />
Am I overlooking something, or is there a better way rather than the Razor shorthand "If" to display the appropriate content?
Thanks
Hi James and welcome to our :)
What version of Umbraco are you using? And is the rendering engine set to use MVC?
If so that's probably the reason why you can't get it to work.
Looking forward to hearing from you.
/Jan
Hi Jan,
Thanks for your reply. I'm using umbraco v 4.11.3. How can I tell if the rendering engine is set to use MVC? I've only started recently with Umbraco so it's all fairly new to me.
Thanks for your help
James
Hi James
Ok then I guess you're not using MVC rendering mode.
But you can check it in the umbracoSettings.config file in the config folder. In here there are a lot of different settings. The one you should look for in this case is <defaultRenderingEngine>webforms</defaultRenderingEngine> - In your case it probably just looks like this, which is fine.
It's just that if it was set to MVC that would probably be the reason why your user control did not work when posting.
Would it be possible for you to try and refactor the Razor calling your user control to use a XSLT macro instead? Must admit that I can't remember if there can be some issues with posting a user control when it's rendered from Razor.
/Jan
is working on a reply...