單擊【Add】按鈕,即可添加AddNews.aspx視圖成功。此文件的核心代碼如下所示:
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <h2> &nb sp; 添¬¨ª加¨®新?聞? </h2> <% using (Html.BeginForm()) {% > <%: Html.ValidationSummary(true) % > <fieldset> &nb sp; <legend>新?聞? </legend> &nbs p; <div class="editor- label"> &nb sp; <%: Html.LabelFor (model => model.Title) %> </div> & nbsp; <div class="editor- field"> &nb sp; <%: Html.TextBoxFor (model => model.Title) %> <%: Html.ValidationMessageFor(model => model.Title) % > </div> <div class="editor- label"> &nb sp; <%: Html.LabelFor (model => model.CreateTime) % > </div> ; <div class="editor- field"> &nb sp; <%: Html.TextBoxFor (model => model.CreateTime, new { @class = "date" })%> <%: Html.ValidationMessageFor (model => model.CreateTime) %> </div> & nbsp; <div class="editor- label"> &nb sp; <%: Html.LabelFor (model => model.Content) % > </div> & nbsp; <div class="editor- field"> &nb sp; <%: Html.EditorFor (model => model.Content) %> <%: Html.ValidationMessageFor(model => model.Content) % > </div> ; <p> &nbs p; <input type="submit" value="添¬¨ª加¨®" /> </p> </fieldset> <% } % > <div> &n bsp; <%: Html.ActionLink("Back to List", "Index","Home") % > </div> </asp:Content>
分析:
在日期文本框中,新增加屬性new { @class = "date" }) ,此Class屬性是為了稍后的日歷控件的顯示。要使日期文本框顯示日期控件,可以使用Jquery UI,方法是:
1、Jquery UI官方網(wǎng)站http://www.jqueryUI.com下載最新的 UI類(lèi)庫(kù)
出處:博客園
責(zé)任編輯:bluehearts
上一頁(yè) Asp.net MVC2.0系列文章-添加操作 [2] 下一頁(yè) Asp.net MVC2.0系列文章-添加操作 [4]
◎進(jìn)入論壇網(wǎng)絡(luò)編程版塊參加討論
|