學習筆記25_MVC前台API

來源:互聯網
上載者:User

標籤:lin   頁面   api   改變   new   return   .text   產生   注意   

**當請求url的規則有所改變時,前台的所有超連結的href都得改,為了避免多處修改,可以href = "< %=url.Action("Controller","Action")%>"

**在Aspx頁面當中,有一些較好用的Api,能再給使用者呈現標籤:

如:直接在某處寫 <%=html.ActionLink("登入","LoginController","LoginAction");%> 那麼,就可以給使用者<a href="LoginController/LoginAction">登入</a>

//也能夠使用ActionLink設定ID,樣式等等

如:使用<%=html.DropDownList("CityList");%>,就能在前台產生下拉式清單,但是,在後台中,要

ViewData["CityList"] = new List<City> {.....}

如:使用<%=html.TextBox("key")%> ,就能<TextBox><%=ViewData["Key"];%></TextBox>

*也能自訂html的擴充方法,publc static String MyApi(this.htmlHelper helper , ...){ return html;} ,注意,要在<%@ import nameSpace ="xxxx"%>

***使用<%: C#Code%>來代替<%= C#Code%>,能使得瀏覽器不會解析由C#所產生的html標籤

***在前台中,也能像後台一樣自由編程,如在一行中,寫<% var obj = ViewData["key"]  as xxxClass%> ,還能在其他行中,編寫<% = obj.Method()%> 

 

學習筆記25_MVC前台API

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.