转载自:http://www.cnblogs.com/chsword/archive/2008/10/06/aspnetmvc_qa.html

1. 用Html.Form生成表单:
<% using (Html.Form(c => c.Create(), FormMethod.Post, new{id="Create",@class="form" })) { %>
表单内容...
<%}%>
2. 为Helper添加事件:

<%= Html.DropDownList( "ddlStats"new { onchange, "changed();" } ) %>
3. DropDownList初始化:

You can implement a DropDown selector as something like as follows, where this example sets a options called "ScaleMode" on a "Camera" object.

This example is a little more complex because I needed to have 3 associated values:

  • (Name) - Name to display to user.
  • (Value) - Value to store in DB.
  • (ConfigValue) - Value to write to config file.

Within the view:

<tr>
    
<td>Scale Mode:</td>
    
<td><%=Html.DropDownList(null"ScaleMode"new SelectList(TheProjectName.Models.Camera.GetScaleModes(), "Value""Name", ViewData.Model.ScaleMode))%></td>
</tr>

Within the Camera model:


Code
And then your CameraController would have something like this:
Code
4. RenderPartial的使用方法:

<% Html.RenderPartial("viewname");%>
5. 连接输出QueryString问题如/html/index?a=b&c=d

Html.ActionLink("xxx","Index","Home",new{a="b",c="d"},null)
6. Html.之后无智能感知:可能是没编译或建的不是Asp.net mvc的Page
7. Asp.net 不显示中文的解决方法:

  • 将页面的culture属性改为中文
  • 母板页中Content-Type改为:<meta http-equiv="Content-Type" c>

8. ReadFromRequest不存在的问题:
  Pv5之后已经去除,请用Request.Form/Param/Request.QueryString读取

  1. Controller中生成URL(根据Controller和View):http://code.google.com/p/mvccontrib/source/browse/trunk/src/MVCContrib/UI/BlockRenderer.cshttp://www.cnblogs.com/chsword/archive/2008/08/06/dotnetmvcframework_controlleraction.html
  2. 繁杂绑定:http://forums.asp.net/t/1329386.aspx
  3. 不想用Session来存TempData:http://www.cnblogs.com/QLeelulu/archive/2008/09/19/1294469.html
  4. 为filter添加日志:http://www.cnblogs.com/AndersLiu/archive/2008/08/26/logging-with-aspnet-mvc-fction-filters.html
  5. 将/home/index重写为/index:http://forums.asp.net/t/1326487.aspx
  6. 使用FCKEditor:http://forums.asp.net/t/1312846.aspx
  7. 使用JQuery:http://www.sethjuarez.com/post/2008/06/Using-JQuery-to-perform-Ajax-calls-in-ASPNET-MVC.aspx
  8. .net2.0sp1/IIS6下运行:http://www.cnblogs.com/chsword/archive/2008/08/06/dotnetmvcframeworknet2_0.html