zoukankan      html  css  js  c++  java
  • 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
    { ...... }            
  • 相关阅读:
    关于欧拉函数
    JavaWeb技术
    jQuery介绍
    Spring之事务管理
    Hibernate课堂笔记
    JSON简介
    Ajax简介
    Java代码生成图片验证码
    JAVA学习笔记——ClassLoader中getResource方法的路径参数
    JAVA OOP学习笔记——多态(polymorphism)
  • 原文地址:https://www.cnblogs.com/SunXiaoLin/p/3396612.html
Copyright © 2011-2022 走看看