以下是如何在常规输出上执行此操作
name:@TempData [“Name”]
但我希望将值传递到文本框
@ Html.TextBoxFor(m => m.Name,“”,new {@class =“textbox”})
答案 0 :(得分:0)
请找参考资料:
https://msdn.microsoft.com/en-in/library/dd394711(v=vs.100).aspx
<form action="/Home/InsertCustomer">
<% if (ViewData["ErrorMessage"] != null) { %>
The following error occurred while inserting the customer data:
<br />
<%= ViewData["ErrorMessage"] %>
<br />
<% } %>
First name:
<input type="text" name="firstName" value="<%= ViewData["FirstName"] %>" />
<br />
Last name:
<input type="text" name="lastName" value="<%= ViewData["LastName"] %>" />
<br />
<input type="submit" value="Insert" />
</form>
答案 1 :(得分:-2)
@{
var name= @TempData["Name"];
}
@Html.TextBoxFor(a=>a.Name,htmlAttributes:new {Value=name})