MVC 2.0 开发备忘

一、 不经后台直接打开控件
 
1.<%  Html.RenderPartial("TreeControl", Model.Groups);%>  //在同一个Controller下

2.<% Html.RenderPartial("~/Views/HR/SelfAbilityIndex.ascx", model%>//在另一个Controller下


二、 按钮(链接)

1 <%=Ajax.ActionLink("编辑", // 显示名
   "UpdateSelfAbility", // 后台Action
   new { abilityGuid = item.PubGuid }, // action 参数
   new AjaxOptions { //Ajax 选项
     UpdateTargetId = "dynamicPanel", //数据显示的容器
     HttpMethod = "get",// 数据模式 get post
     InsertionMode = InsertionMode.Replace }//更新方式 替换,插入等
  )%>

三、 数据绑定

1.  <%: Html.TextBoxFor(model => model.AbilityDesc, new { Style = "width:20px;height:30px;" })%> 
     // 为 AbilityDesc 属性建立一个TextBox 控件 后面是控件的样式 再回送的FormCollection 里可以通过 form["AbilityDesc"]  找到

四、C# 使用 

  1. string 的 split(",") 按 ,切开字符串

  2 可在classDiagram写注释

  3 static class 不能参与继承

  4  反射  using System.Reflection; 

                PropertyInfo[] infos = typeof(T).GetProperties();
                PropertyInfo  a = infos[1];

 
五、界面元素赋值

  1. 可以通过<input id ="<%= item,Title %>"/>的方法赋id值其他类似

 
六、其他   1. Action 的参数名不能是 “id”  
   2. Action 去除缓存 [OutputCache( VaryByParam = "none")]
     

posted @ 2011-08-02 23:17  Ghost_zhao  阅读(446)  评论(2编辑  收藏  举报