Closed Guzzy711 closed 7 years ago
Hi @GuzzyMedia,
Looks like you're trying to render a block of Razor within a WebForms template? That won't work :)
Form Editor has no official support for WebForms. If you want to use it in a WebForms context, you'll have to create your own rendering from scratch.
Alternatively you might be able to move the Razor to a macro. Not sure if it'll work, nor how it'll perform (you'll efficiently be mixing two different rendering engines in one page rendering).
-Kenn
Hello Thanks for the fast response! The thing is, that i'm trying to implement your form into a content page, but i'm not sure where to put the razor.. The template, our content page is using is a webform, and I find it as the only place I can put it into... Do you have the time to help me out?
I've just tried doing it with a macro.. Can't see what i'm doing wrong.. :(
The log files should probably give you some clues as to what's wrong with your code. My guess is you need to close the code block before calling @Html.Partial(...)
.
I just tried creating a WebForms master page that calls a Razor macro with the Form Editor rendering. Looks like it works just fine.
Keep in mind though that you're still mixing WebForms and Razor in the same rendering, which might have a performance impact. Also there might just be Form Editor specific things that simply won't work with this solution, as it's never been tested like this.
Here's the master page:
<%@ Master Language="C#" MasterPageFile="~/umbraco/masterpages/default.master" AutoEventWireup="true" %>
<asp:Content ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server">
<!DOCTYPE html>
<html>
<head>
<title>Test WebForms</title>
<link rel="stylesheet" href="http://getbootstrap.com/dist/css/bootstrap.min.css"/>
<style>
/* required field indicator on the field labels */
div.form-group.required > label:after {
content: ' *';
color: #a94442;
}
</style>
</head>
<body>
<umbraco:macro alias="FormEditorMacro" runat="server" />
</body>
</html>
</asp:Content>
...and here's the macro (I've used the NoScript rendering for simplicity, but it can be whatever):
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@* render the form with the NoScript partial *@
@Html.Partial("FormEditor/NoScript", Umbraco.AssignedContentItem)
You're amazing! You just saved my day..
It was my macro that had some difficulties..
As you can see, i'm still pretty new to Umbraco, so i learned alot from this! 👍
Thanks alot!
You're welcome. Glad you got it working.
As you can see, i got rendering issues? What did i do wrong? :)