Search code examples
asp.net-mvcasp.net-mvc-4telerikrazorengine

MVC Model Property Binding in pop-up template editor


I am using Telerik MVC Grid with a pop-up editor. I have an editor template defined with the following code, and it is working. However, it seems like the model binding only works with certain methods that take a lambda expression (@Html.EditorFor, @Html.TextBoxFor, etc). If I simply wanted to make a model property appear as raw html/text in the page - how is that done? I have tried using the @Model.Property syntax - and it does not produce an error, but no value is output. What am I overlooking here?

@model Models.MatrixConditionViewModel


<div style="padding:5px;margin:5px;width:975px;border:1px solid black;" class="form-horizontal m-t-md">

    <h3>Edit Condition</h3>
    <br />    

    <div class="form-group">
        @Html.HiddenFor(model => model.ConditionId)

        <label class="col-sm-2 control-label">Condition</label>
        @Html.TextBoxFor(model => model.ConditionName, new { @class = "col-sm-3" })
        @Html.ValidationMessageFor(model => model.ConditionName)

        <label class="col-sm-2 control-label">Desc</label>
        @Html.TextAreaFor(model => model.ConditionDescription, 3, 25, null)
        @Html.ValidationMessageFor(model => model.ConditionDescription)

    </div>

    <div class="form-group">
        <label class="col-sm-2 control-label">Logic</label>
        @Html.TextAreaFor(model => model.ConditionLogic, 5, 94, null)
        @Html.ValidationMessageFor(model => model.ConditionLogic)
    </div>

    <div class="form-group">             
        Need a value here: @Model.ConditionId
        <label  class="col-sm-2 control-label">Content</label>            
        <iframe src="~/WebForms/ContentEditor.aspx?ConditionId=1" width="700" height="425" frameborder="0"></iframe>         

    </div>

    <div class="form-group">
        <label class="col-sm-2 control-label">Font Formatting</label>
        @Html.TextAreaFor(model => model.ConditionFormatNotes, 5, 94, null)
        @Html.ValidationMessageFor(model => model.ConditionFormatNotes)
    </div>
</div>

Solution

  • Use the Html.Raw HTML helper to render the property

    @Html.Raw(Model.PropertyName)
    

    If you want this to then be bound by the modebinder, you have to make sure the input name matches the params (and types of params) of the action method that is receiving the request.