我认为有一个字段被调用Comments
,每次我<
在“输入”中的任何其他字符(字母等)之前包含in 时,都没有调用动作控制器,我认为是因为无法正确解析串起来,
这是我的类中的属性的声明方式:
[Display(Name = "Comments"), DataType(DataType.MultilineText)]
public string my_comments { get; set; }
当我输入任何单词时它工作正常,例如:
dog
, [email protected]
,>asa?
但如果我尝试这样的事情:
<[email protected]>
, <p
, <asa>
,asasd<f
没有调用该操作,我认为是因为这无法将输入解析为字符串...
如果我<
在最后包含字符,它通过没问题..,例如:
ddd<
我在我看来使用 JQuery:
$("#btnSubmit").click(function () {
$.ajax({
type: 'post',
url: $("#btnSubmit").data("url"),
data: $("#formEd").serialize(),
success: function (result) {
....
}})
})
网址:
<div class="form-group">
<div class="control-label col-md-2">Comments</div>
<div class="col-md-5">
@Html.EditorFor(model => model.my_comments , new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.my_comments , "", new { @class = "text-danger" })
</div>
</div>
还有我的动作控制器:
[HTTPPost]
public ActionResult MyAction(MyClass parameter) // where MyClass contains the my_comments property...
您可以添加一个属性来禁用输入验证,但您必须确保您确定要允许 html。
[ValidateInput(false)]
[HTTPPost]
public ActionResult MyAction(MyClass parameter)
您还可以将该属性添加到您的变量中以允许使用 html。
[Display(Name = "Comments"), DataType(DataType.MultilineText)]
[AllowHtml]
public string my_comments { get; set; }
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句