飞艇价格:ASP.NET一些常用的技巧

来源:百度文库 编辑:九乡新闻网 时间:2024/07/14 05:46:59

ASP.NET一些常用的技巧

//如果新闻标题大于某个值就让它后面的省掉
public   string   shengyue(string   str,   int   Int)    
  {    
   if   (str.Length   <=   Int)    
   {    
    return   str;    
   }    
   else    
   {    
    str   =   str.Substring(0,Int)   +   "...";    
    return   str;    
   }    
  }
HTML代码:<%# shengyue(DataBinder.Eval(Container.DataItem,"title").ToString(),13)%>


//防止刷新重复提交:

Response.Write("");

//后台调用前台脚本验证代码
Button1.Attributes.Add("onclick" ,"javascript:data();");

//插入一条数据后立即获取这条ID的值
string   strSql_InsertFlow   =   "insert   into   data_news(title,body)   values('"+title.Trim()+"','"+body.Trim()+"');select   @@identity   as 'newid'";

//禁止后退按钮
Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);