此文仅用于记录下此项目的经验教训,不做他用。
1、这次项目碰到的最大的问题是客户端验证;那几天测试人员几乎把我逼疯了,所以后来狠下决心专研了几个验证框架,主要有jquery.valicate.js和猫冬的jquery.formvalicateor.js。经过最好筛选,选择了猫冬的formvalicateor,主要是jquery.valicate.js 不好控制错误提示样式或者说不能自定义错误信息的显示标签,这点我不知道园子里的人知道有没有,我会继续研究这个框架的,对于猫冬的formvalicateor,基本能实现所有的验证,但他有一点那就是在页面中要写大堆的js代码,而jquery.valicate.js 只需要写个css="验证类型"就行了。具体的这个框架的比较这几天我会继续研究,可能会写篇文章做比较。
2、这次项目用的是nettiers 生成的。主要在生成的视图的分页出现了问题,如: VList<V_OperationLog_UserInfo> vList = BLL.Provider.OperationLogProvider.ViewGetPaged(StrWhere, "CreateTime asc", (pagerForListBottom.CurrentPageIndex - 1) * pagerForListBottom.PageSize, pagerForListBottom.PageSize, out outCount);
以前(pagerForListBottom.CurrentPageIndex - 1) * pagerForListBottom.PageSize这句直接就是pagerForListBottom.CurrentPageIndex - 1,但这次如果这样的话就会翻一页就只翻一条数据。据说这个nettiers一个bug,但以前的项目也是nettiers生成的,就只需写pagerForListBottom.CurrentPageIndex - 1。不知道什么原因,还需要去细研究。
3、Repeater 内绑定DropDownList,用于列表排序, 当DropDownList 值改变,这个整个列表按照新的排序显示。 主要用到了Repeater 的OnItemDataBound,绑定DropDownList的各项值。 当DropDownList 值改变时,相应DropDownList 的OnSelectedIndexChanged事件。这个还要注意,要记住修改的那个对象,我这里用了个labal来记住修改的对象id,客户端代码:
Code
1 <asp:Repeater ID="RptRoleList" runat="server" OnItemDataBound="RptRoleList_OnItemDataBound">
2 <ItemTemplate>
3 <tr>
4 <td >
5 <asp:DropDownList ID="DdlSort" runat="server" AutoPostBack="true" OnSelectedIndexChanged="Rpt_DdlSort_OnSelectedIndexChanged" ></asp:DropDownList><asp:Label ID="LabId" runat="server" Visible="false" Text='<%#Eval("TopCategoryId")%>'></asp:Label>
6 </td>
7 </tr>
8 </ItemTemplate>
9 </asp:Repeater> 后台程序:
Code
1 Rpt_DdlSort_OnSelectedIndexChanged(object sender,EventArgs e)
2 {
3 DropDownList ddlSort=(DropDownList)sender;
4
5 int newvalue = ConvertHelper.GetInteger(ddlSort.SelectedItem.Text);
6 int keyid = 0;//需要修改的对象id
7 RepeaterItem item = ((DropDownList)sender).Parent as RepeaterItem; //转为所在Item
8 if(item!=null)
9 {
10 Label LabFId = item.FindControl("LabId") as Label; //查找
11 keyid = ConvertHelper.GetInteger(LabFId.Text);
12 }
13 }
14
15
1、这次项目碰到的最大的问题是客户端验证;那几天测试人员几乎把我逼疯了,所以后来狠下决心专研了几个验证框架,主要有jquery.valicate.js和猫冬的jquery.formvalicateor.js。经过最好筛选,选择了猫冬的formvalicateor,主要是jquery.valicate.js 不好控制错误提示样式或者说不能自定义错误信息的显示标签,这点我不知道园子里的人知道有没有,我会继续研究这个框架的,对于猫冬的formvalicateor,基本能实现所有的验证,但他有一点那就是在页面中要写大堆的js代码,而jquery.valicate.js 只需要写个css="验证类型"就行了。具体的这个框架的比较这几天我会继续研究,可能会写篇文章做比较。
2、这次项目用的是nettiers 生成的。主要在生成的视图的分页出现了问题,如: VList<V_OperationLog_UserInfo> vList = BLL.Provider.OperationLogProvider.ViewGetPaged(StrWhere, "CreateTime asc", (pagerForListBottom.CurrentPageIndex - 1) * pagerForListBottom.PageSize, pagerForListBottom.PageSize, out outCount);
以前(pagerForListBottom.CurrentPageIndex - 1) * pagerForListBottom.PageSize这句直接就是pagerForListBottom.CurrentPageIndex - 1,但这次如果这样的话就会翻一页就只翻一条数据。据说这个nettiers一个bug,但以前的项目也是nettiers生成的,就只需写pagerForListBottom.CurrentPageIndex - 1。不知道什么原因,还需要去细研究。
3、Repeater 内绑定DropDownList,用于列表排序, 当DropDownList 值改变,这个整个列表按照新的排序显示。 主要用到了Repeater 的OnItemDataBound,绑定DropDownList的各项值。 当DropDownList 值改变时,相应DropDownList 的OnSelectedIndexChanged事件。这个还要注意,要记住修改的那个对象,我这里用了个labal来记住修改的对象id,客户端代码:
![ContractedBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![ExpandedBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
1 <asp:Repeater ID="RptRoleList" runat="server" OnItemDataBound="RptRoleList_OnItemDataBound">
2 <ItemTemplate>
3 <tr>
4 <td >
5 <asp:DropDownList ID="DdlSort" runat="server" AutoPostBack="true" OnSelectedIndexChanged="Rpt_DdlSort_OnSelectedIndexChanged" ></asp:DropDownList><asp:Label ID="LabId" runat="server" Visible="false" Text='<%#Eval("TopCategoryId")%>'></asp:Label>
6 </td>
7 </tr>
8 </ItemTemplate>
9 </asp:Repeater>
![ContractedBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![ExpandedBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
1 Rpt_DdlSort_OnSelectedIndexChanged(object sender,EventArgs e)
2 {
3 DropDownList ddlSort=(DropDownList)sender;
4
5 int newvalue = ConvertHelper.GetInteger(ddlSort.SelectedItem.Text);
6 int keyid = 0;//需要修改的对象id
7 RepeaterItem item = ((DropDownList)sender).Parent as RepeaterItem; //转为所在Item
8 if(item!=null)
9 {
10 Label LabFId = item.FindControl("LabId") as Label; //查找
11 keyid = ConvertHelper.GetInteger(LabFId.Text);
12 }
13 }
14
15