![](/img/trans.png)
[英]How to get Single Object in Controller from List of Objects using Razor View in ASP.NET MVC
[英]In ASP.NET MVC 3, how do I get at the model using Razor Syntax in a Create() View?
如何獲取文本區域中的數據並將其填充到模型中?
我在Create()視圖中,我想訪問模型,以將
<textarea>
放入模型的屬性之一(本例中為Content屬性)。
namespace TestTinyMCE.Models {
public class TestBlog {
public int TestBlogId { get; set; }
public string Title { get; set; }
public DateTime PostedOn { get; set; }
public string Tags { get; set; }
public string Content { get; set; }
}
}
我接受HTML標記(粗體,斜體等)時無法使用TextAreaFor。 如果重要的話,我在我的文本區域上使用TinyMCE。
我試圖通過JQuery的.submit API鈎住Submit事件:
<script type="text/javascript">
$(document).ready(function () {
tinyMCE.init({
theme: "advanced",
mode: "textareas"
});
$('#contentEditor').submit(function () {
alert('Handler for .submit() called.');
return false;
});
});
</script>
但是.submit()出現在$(document).ready中時,處理程序本身從未觸發。
這是我的文本區域:
<div class="editor-field">
<textarea id="contentEditor" name="contentEditor"></textarea>
</div>
我接受HTML標記(粗體,斜體等)時無法使用TextAreaFor。 如果重要的話,我在我的文本區域上使用TinyMCE。
錯誤。
TextAreaFor()
會像您一樣發出普通的<textarea>
。 您仍然可以將TinyMCE連接到它。
您的實際問題是<textarea>
不會觸發submit
事件。
您需要處理<form>
的submit
事件。
但是,您實際上根本不需要這樣做。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.