分享

ASP.NET一些常用的技巧 - 哇哈哈o(∩_∩)o... - 博客园

 suweixin 2011-01-15

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("<script language='javascript'>alert('信息发表成功!');window.location = '" + Request.Url +"'</script>");

//后台调用前台脚本验证代码
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);


    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约