• asp.net 代码 注意点


    1. 模糊查询时,注意要去掉空格

    前台:

     <input id="txtQJBH" type="text" runat="server" />

    后台:

            protected void btnSearch_Click(object sender, EventArgs e)
            {
                if (txtQJMC.Value != string.Empty)
                {
                    where += " and applianceName like '%" + txtQJMC.Value.Trim() + "%'"; //此处注意去掉空格,否则查不到数据
                }
                Bind();
            }    

     2. 在[WebMethod]中引用Session:

    string userID=Convert.ToInt32(HttpContext.Current.Session["UserID"].ToString());

    3. Repeater获取具体年、月,后台方法

          public string GetYear(DateTime time)
            {
                string str = "" ;
                if (time != null )
                {
                    str = time.Year.ToString();
                }
                return str;
            }
            public string GetMonth(DateTime time)
            {
                string str = "" ;
                if (time!=null )
                {
                    str = time.Month.ToString();
                }
                return str
            }

    4. 页面打印功能:

    <a onclick="window.print();" style="float:right;color:Blue;cursor:pointer;" class="noprint">打印 </a>
    
    <style type="text/css" media="print">
        .noprint
        {
            display: none ;
        }
        .print
        {
            display: block ;
        }
    </style>

     5. 后台对数据库bit类型的判断

    object isModify = DBUility.DbHelperSQL.GetString("select rightsModify from tb_user where userName='"+ userName +"';");
    if(isModify.ToString()=="False")//权限未修改过   此处注意,从数据库中读取bit类型数据判断时,要根据"True" or "False",注意大小写    
    { ...... }
    else
    { ...... }            
  • 相关阅读:
    菜鸡的Java笔记 第二十八
    菜鸡的Java笔记 第二十七
    菜鸡的Java笔记 第二十六
    菜鸡的Java笔记 第二十五 wrapperClass 包装类
    bzoj3238 [Ahoi2013]差异
    bzoj4516 [Sdoi2016]生成魔咒
    bzoj3998 [TJOI2015]弦论
    bzoj1965 [Ahoi2005]洗牌
    bzoj4896 [Thu Summer Camp2016]补退选
    bzoj5055 膜法师
  • 原文地址:https://www.cnblogs.com/SunXiaoLin/p/3396612.html
Copyright © 2020-2023  润新知