Hi!
This is a very simple example of how to change the property of a textobox. The code bellow is related to a EDIT functionality.
<%: Html.TextBoxFor(model => model.CustomerID,
new { @readonly = "true", @disable = "true", size = 5, maxlength = 5,
style = "background-color:yellow"})%>
Very simple. Isn't it?
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MvcApplication5.Models.CustomerModel>" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Edit
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2>Edit</h2>
<% using (Html.BeginForm()) {%>
<%: Html.ValidationSummary(true) %>
<fieldset>
<legend>Fields</legend>
<div class="editor-label">
<%: Html.LabelFor(model => model.CustomerID) %>
</div>
<div class="editor-field">
<%: Html.TextBoxFor(model => model.CustomerID, new { @readonly = "true", @disable = "true", size = 5, maxlength = 5, style = "background-color:yellow"})%> <%: Html.ValidationMessageFor(model => model.CustomerID) %>
</div>
<div class="editor-label">
<%: Html.LabelFor(model => model.CompanyName) %>
</div>
<div class="editor-field">
<%: Html.TextBoxFor(model => model.CompanyName) %>
<%: Html.ValidationMessageFor(model => model.CompanyName) %>
</div>
<p>
<input type="submit" value="Save" />
</p>
</fieldset>
<% } %>
<div>
<%: Html.ActionLink("Back to List", "Index") %>
</div>
</asp:Content>
Há!
Nenhum comentário:
Postar um comentário