如何在 ASP.NET MVC3 Razor 中创建只读文本框 [英] How to create a readonly textbox in ASP.NET MVC3 Razor

查看:29
本文介绍了如何在 ASP.NET MVC3 Razor 中创建只读文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 Razor 视图引擎在 ASP.NET MVC3 中创建只读文本框?

How do I create a readonly textbox in ASP.NET MVC3 with the Razor view engine?

是否有 HTMLHelper 方法可以做到这一点?

Is there an HTMLHelper method available to do that?

类似于以下内容?

@Html.ReadOnlyTextBoxFor(m => m.userCode)

推荐答案

@Html.TextBoxFor(m => m.userCode, new { @readonly="readonly" })

欢迎您为此创建一个 HTML Helper,但这只是一个 HTML 属性,就像其他任何属性一样.您会为具有其他属性的文本框制作 HTML Helper 吗?

You are welcome to make an HTML Helper for this, but this is simply just an HTML attribute like any other. Would you make an HTML Helper for a text box that has other attributes?

这篇关于如何在 ASP.NET MVC3 Razor 中创建只读文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆