当前位置:首页 > 网络编程 > WEB编程 > ASP.net >  asp.net程序中最常用的三十三种编程代码2

 asp.net程序中最常用的三十三种编程代码2

点击次数:30 次 发布日期:2008-11-26 11:36:21 作者:源代码网
源代码网推荐      6.表格超连接列传递参数
源代码网推荐  
源代码网推荐  <asp:HyperLinkColumn Target="_blank" headertext="ID号" DataTextField="id" NavigateUrl="aaa.aspx?id=’
源代码网推荐   <%# DataBinder.Eval(Container.DataItem, "数据字段1")%>’ & name=’<%# DataBinder.Eval(Container.DataItem, "数据字段2")%>’ />
源代码网推荐  
源代码网推荐    7.表格点击改变颜色
源代码网推荐  
源代码网推荐  if (e.Item.ItemType == ListItemType.Item ||e.Item.ItemType == ListItemType.AlternatingItem)
源代码网推荐  {
源代码网推荐   e.Item.Attributes.Add("onclick","this.style.backgroundColor=’#99cc00’;
源代码网推荐      this.style.color=’buttontext’;this.style.cursor=’default’;");
源代码网推荐  }
源代码网推荐  
源代码网推荐    写在DataGrid的_ItemDataBound里
源代码网推荐  
源代码网推荐  if (e.Item.ItemType == ListItemType.Item ||e.Item.ItemType == ListItemType.AlternatingItem)
源代码网推荐  {
源代码网推荐  e.Item.Attributes.Add("onmouseover","this.style.backgroundColor=’#99cc00’;
源代码网推荐     this.style.color=’buttontext’;this.style.cursor=’default’;");
源代码网推荐  e.Item.Attributes.Add("onmouseout","this.style.backgroundColor=’’;this.style.color=’’;");
源代码网推荐  }
源代码网推荐  
源代码网推荐  
源代码网推荐    8.关于日期格式
源代码网推荐  
源代码网推荐    日期格式设定
源代码网推荐  
源代码网推荐  DataFormatString="{0:yyyy-MM-dd}"
源代码网推荐  
源代码网推荐    我觉得应该在itembound事件中
源代码网推荐  
源代码网推荐  e.items.cell["你的列"].text=DateTime.Parse(e.items.cell["你的列"].text.ToString("yyyy-MM-dd"))
源代码网推荐  
源代码网推荐    9.获取错误信息并到指定页面
源代码网推荐  
源代码网推荐    不要使用Response.Redirect,而应该使用Server.Transfer
源代码网推荐  
源代码网推荐    e.g
源代码网推荐  
源代码网推荐  // in global.asax
源代码网推荐  protected void Application_Error(Object sender, EventArgs e) {
源代码网推荐  if (Server.GetLastError() is HttpUnhandledException)
源代码网推荐  Server.Transfer("MyErrorPage.aspx");
源代码网推荐  
源代码网推荐  //其余的非HttpUnhandledException异常交给ASP.NET自己处理就okay了 :)
源代码网推荐  }
源代码网推荐  
源代码网推荐    Redirect会导致post-back的产生从而丢失了错误信息,所以页面导向应该直接在服务器端执行,这样就可以在错误处理页面得到出错信息并进行相应的处理
源代码网推荐  
源代码网推荐    10.清空Cookie
源代码网推荐  
源代码网推荐  Cookie.Expires=[DateTime];
源代码网推荐  Response.Cookies("UserName").Expires = 0
源代码网推荐  
源代码网推荐    做人要厚道,请注明转自酷网动力(www.ASPCOOL.COM)。
源代码网推荐


源代码网供稿.
网友评论 (0)
会员中心
网络编程
本站推荐
网络编程之精华