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