Asp.net mvc 2 如何为<;设置MVC TEXTAREA的默认值&燃气轮机;盒?
好的,这是我的情况,到现在为止。。。戏剧性的停顿 我的MVC视图中的框有以下文本区域:Asp.net mvc 2 如何为<;设置MVC TEXTAREA的默认值&燃气轮机;盒?,asp.net-mvc-2,textarea,default-value,Asp.net Mvc 2,Textarea,Default Value,好的,这是我的情况,到现在为止。。。戏剧性的停顿 我的MVC视图中的框有以下文本区域: <div class="editor-label"> <%: Html.LabelFor(model => model.Monday) %> </div> <div class="editor-field"> <%: Html.TextAreaFor(mo
<div class="editor-label">
<%: Html.LabelFor(model => model.Monday) %>
</div>
<div class="editor-field">
<%: Html.TextAreaFor(model => model.Wednesday, 6, 40, new { })%>
<%: Html.ValidationMessageFor(model => model.Monday) %>
</div>
<div class="editor-label">
<%: Html.LabelFor(model => model.Wednesday) %>
</div>
<div class="editor-field">
<%: Html.TextAreaFor(model => model.Wednesday, 6, 40, new {})%>
<%: Html.ValidationMessageFor(model => model.Wednesday) %>
</div>
<div class="editor-label">
<%: Html.LabelFor(model => model.Friday) %>
</div>
<div class="editor-field">
<%: Html.TextAreaFor(model => model.Friday, 6, 40, new {}) %>
<%: Html.ValidationMessageFor(model => model.Friday) %>
</div>
可以在呈现此视图的控制器操作中执行此操作:
public ActionResult Index()
{
MyViewModel model = ...
model.Friday = "some default value";
return View(model);
}
您将有一个相应的POST操作,该操作将检索值:
[HttpPost]
public ActionResult Index(MyViewModel model)
{
// model.Friday will contain the text entered by the user in the corresponding textarea
// here you could store for example the values in the database
...
}
另一个快速问题(问题概念)是我是否保存了这些数据
textAreas到数据库(使用SQLServerExpress2008),会吗
保留新行字符
是的,您只需要将文本按原样保存在数据库中,而无需进行任何转换。当您稍后在文本区域中显示文本时,这将起作用,但如果您想在
中显示文本,则必须对其进行HTML编码,并用
替换新行。例如,您可以为此作业编写一个脚本。您可以在呈现此视图的控制器操作中执行此操作:
public ActionResult Index()
{
MyViewModel model = ...
model.Friday = "some default value";
return View(model);
}
您将有一个相应的POST操作,该操作将检索值:
[HttpPost]
public ActionResult Index(MyViewModel model)
{
// model.Friday will contain the text entered by the user in the corresponding textarea
// here you could store for example the values in the database
...
}
另一个快速问题(问题概念)是我是否保存了这些数据
textAreas到数据库(使用SQLServerExpress2008),会吗
保留新行字符
是的,您只需要将文本按原样保存在数据库中,而无需进行任何转换。当您稍后在文本区域中显示文本时,这将起作用,但如果您想在
中显示文本,则必须对其进行HTML编码,并用
替换新行。例如,您可以为此作业编写一个。感谢您的快速响应,我将检查它。换行符将按环境分割。换行符将放置在下拉菜单中,供用户从菜单中选择,在构建包含IEnumerable
属性的视图模型时,您可以在控制器操作中执行此拆分。感谢您的快速响应,我将检查它。换行符将按环境进行拆分。换行符将放置在下拉菜单中,供用户从菜单中选择,在构建包含IEnumerable
属性的视图模型时,可以在控制器操作中执行此拆分。