DevExpress MVC HTMLEditor - 在编辑模式下,它不会在HtmlEditor中呈现模型属性值

时间:2016-05-16 14:08:33

标签: javascript c# asp.net-mvc razor devexpress-mvc

我创建了一个局部视图,在其中定义HtmlEditor并将其与Model属性绑定。 它将根据下拉值选择显示内容。 因此,第一次加载父视图和内部父视图时,它将向HtmlEditor显示Model Property的值,但是当我更改下拉值并使用更新的值呈现局部视图时,它将不会显示更新的内容。

AddEditHelpContent.chtml: -

 <div class="form-group">
        <div>
            <label class="set-lable">Language</label>
        </div>
        <div>
            @Html.DevExpress().ComboBoxFor(x => x.languageId, settings =>
            {
                settings.Name = "Language";
                settings.Properties.TextField = "Text";
                settings.Properties.ValueField = "Value";
                settings.Properties.ValueType = typeof(string);
                settings.SelectedIndex = 0;
                settings.Properties.ClientSideEvents.SelectedIndexChanged = "LanguageDropDownChange";
            }).BindList(Model.LstLanguage).Bind(Model.languageId).GetHtml()

        </div>    
    </div>

    <div class="form-group">
        <div>
            <label class="set-lable">Content</label>
        </div>

        <div style="height:70%; width:75%;float:right;">
              @Html.Partial("_FeaturesPartial", Model)
        </div>
    </div>

[JS]

var selectedLanguage =""
function LanguageDropDownChange(s,e)
{
    if (s != undefined)
        selectedLanguage = s.GetValue();

    htmlContent.PerformDataCallback()
}


function HtmlEditor_BeginCallback(s, e)
{
    HtmlEditor_BeginCallback
    e.customArgs['Language'] = selectedLanguage;
}

function HtmlEditor_EndCallback(s, e)
{

}

function HtmlEditor_LostFocus(s, e)
{

}

_FeaturesPartial.chtml: -

@model OneShip.Models.HelpManagment

@using DevExpress.Utils;
@using DevExpress.Web.ASPxHtmlEditor;
@using DevExpress.Web.Mvc;

@if (!string.IsNullOrEmpty(Model.htmlContent))
{
    ViewBag.tempdata = Model.htmlContent;
}

@Html.DevExpress().HtmlEditor(
                            settings =>
                            {
                                settings.Name = "htmlContent";
                               settings.CustomDataActionRouteValues = new { Controller = "HelpManagement", Action = "FeaturesPartial"};
                                settings.Theme = "OneShipTheme";
                                settings.Html = "";
                                settings.Html = Convert.ToString(ViewBag.tempdata);
                                settings.SettingsHtmlEditing.AllowScripts = true;
                                settings.Settings.AllowHtmlView = true;
                                settings.Settings.AllowPreview = true;
                                settings.Settings.AllowDesignView = true;
                                settings.ClientSideEvents.BeginCallback = "HtmlEditor_BeginCallback";
                                settings.ClientSideEvents.EndCallback = "HtmlEditor_EndCallback";
                                settings.ClientSideEvents.LostFocus = "HtmlEditor_LostFocus";
                            }).GetHtml()

HelpManagementController: -

  [HttpGet]
        public ActionResult AddEditHelpContent()
        {
            HelpManagment model = new HelpManagment();
            model.LstLanguage = Common.GetAllLanguage();
            model.htmlContent = "<b>First Time Loaded Value in HTML Editor </b>";
            return View(model);
        }


    public ActionResult FeaturesPartial()
        {
            HelpManagment model = new HelpManagment();
            model.htmlContent = "<b> Based on Language selection HTML content updated in HTML Editor</b>";
            return PartialView("_FeaturesPartial",model);
        }

型号: -

public class HelpManagment
{
       public string languageId { get; set; }
       public IEnumerable<SelectListItem> LstLanguage { get; set; }
       [AllowHtml]
       public string htmlContent { get; set; }
}

0 个答案:

没有答案