ASP.Net MVC 应用程序中的编辑文本框不起作用?

发布于 2024-08-13 17:43:04 字数 466 浏览 2 评论 0原文

由于目前未知的原因,在处理使用“编辑”模板的自动脚手架创建的编辑的强类型部分视图中,拒绝在文本框中显示任何数据。

但是,测试标题文本字符串显示相关内容。

<% using (Html.BeginForm()) {

try
{
%>

<fieldset>
<legend>Fields</legend>

<p>

<% 
string titletext = Model.Title.ToString();
%>

<%= titletext %>

<label for="Title">Title:</label>
<%= Html.TextBox("Title", Model.Title) %>
<%= Html.ValidationMessage("Title", "*") %>

</p>

For reasons currently unknown, in a strongly typed partial view that handles editing which was created using the auto-scaffold for an "Edit" template, refuses to display any data in the textbox.

But, the test titletext string displays the relevent content.

<% using (Html.BeginForm()) {

try
{
%>

<fieldset>
<legend>Fields</legend>

<p>

<% 
string titletext = Model.Title.ToString();
%>

<%= titletext %>

<label for="Title">Title:</label>
<%= Html.TextBox("Title", Model.Title) %>
<%= Html.ValidationMessage("Title", "*") %>

</p>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

等待圉鍢 2024-08-20 17:43:04

确保您放入文本框中的文本不包含 html 标签 - 尝试对您的文本进行 html.encode。

在 MVC 2 中,这是自动处理的。

编辑:
Model.Title 属性是否与页面级标题变量冲突?

Make sure the text you put into the textbox doesn't contain html tags - try to html.encode your text.

In MVC 2 this is handled automagically.

Edit:
Isn't the Model.Title property in conflict with Page-level Title variable?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文