在这里,我想设置readonly属性到一个按钮点击/动作点击文本框。 我该怎么做。 在初始页面,数据以只读方式显示,并在编辑按钮上单击。 这应该改为可编辑的文本框。我有几乎七个文本框我需要为所有人做同样的事情。
<div class="editor-label" style="position:static"> <%: Html.LabelFor(Model => Model.Date, "Date")%> <span style="padding-left:52px"> <%: Html.TextBoxFor(Model => Model.Date)%>Here i want to set the readonly property to the textbox on a button click/Action Click. how do i do it. At the initial page the data is been displayed as readonly and on the edit button click. This should be changed to editable textbox.I have almost seven textboxes i need to do the same for all.
最满意答案
如果我正确理解你的问题,这可以用一个小小的JavaScript来完成。 这是一个简单的例子。
在页面加载时将每个文本框渲染为只读:
<%: Html.TextBoxFor(model => model.Date, new { @readonly = "readonly" }) %>为您的编辑按钮添加一个单击处理程序,该处理程序将从每个文本框中删除readonly属性:
$("#editButton").click(function() { $("#Date").removeAttr("readonly"); });If I understand your question correctly, this can be accomplished with a little javascript. Here's a simple example.
Render each textbox as readonly on page load:
<%: Html.TextBoxFor(model => model.Date, new { @readonly = "readonly" }) %>Add a click handler for your edit button that will remove the readonly attribute from each textbox:
$("#editButton").click(function() { $("#Date").removeAttr("readonly"); });更多推荐
readonly,文本框,按钮,button,电脑培训,计算机培训,IT培训"/> <meta name="descri
发布评论