我可以设置文本框使用Html.TextBoxFor时为只读? [英] Can I set text box to readonly when using Html.TextBoxFor?

查看:1573
本文介绍了我可以设置文本框使用Html.TextBoxFor时为只读?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Html.TextBoxFor前pression下面的标记,我想是只读的内容,这可能吗?

 <%= Html.TextBoxFor(M = GT; Model.Events.Subscribed [I] .Action)%GT;


解决方案

 <%= Html.TextBoxFor(型号=> Model.SomeFieldName,新的字典<字符串对象>( ){{只读,真}})%GT;

知不知道这是不是一个安全的方式做到这一点的人可以注入javascript来改变这种状况。

I have the following tag with a Html.TextBoxFor expression and I want the contents to be read only, is this possible?

<%= Html.TextBoxFor(m => Model.Events.Subscribed[i].Action)%>

解决方案

<%= Html.TextBoxFor(model => Model.SomeFieldName, new Dictionary<string, object>(){{"readonly", "true"}}) %>

Do realize that this is not a "secure" way to do this as somebody can inject javascript to change this.

这篇关于我可以设置文本框使用Html.TextBoxFor时为只读?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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