.net开发经验收集

 =================================
css中超链接的样式顺序不可搞错,先link再visited再hover再active
这样效果最好
如:
a.news:link {
 font-family: "宋体";
 font-size: 12px;
 color: #666666;
 text-decoration: none;
}
a.news:visited {
 font-family: "宋体";
 font-size: 12px;
 color: #666666;
 text-decoration: none;
}
a.news:hover {
 font-family: "宋体";
 font-size: 12px;
 color: #000000;
 text-decoration: underline;
}
a.news:active {
 font-family: "宋体";
 font-size: 12px;
 color: #000000;
 text-decoration: underline;
}
==================================
textbox设置为password时动态添加文字不会添加的解决方法:
txtPassword.Attributes.Add("value",curUser.sPassWord.Trim());
==================================
//出错默认转到出错页面
    void Application_Error(object sender, EventArgs e)
    {
        // 在出现未处理的错误时运行的代码
        Exception errorInfo = Server.GetLastError().InnerException;
        string strMessage = "错误信息:" + Server.UrlEncode(errorInfo.Message);
        string strPageUrl = Request.Path;
        strMessage += "出错页面路径:" + strPageUrl;
        Server.ClearError();
        Response.Redirect("~//Error.aspx?ErrInfo=" + strMessage, true);

    }
===================================
select isnull(@s1,'uffjf') sql语句中判断为空则值默认为后面的参数
判断是否为null是 if (@param is null)不是if (@param = null)
===================================
在formview里面做dropdownlist的数据联动时会出错,可以不绑定,而在代码中(inserting或updateing时)添加params的defaultvalue就可以解决
===================================
新打开一页asp.net控件:
ImageButton1.Attributes.Add("onclick", "javascript:window.open('XXX.aspx','_blank');return false");
===================================
客户端可以myinput.focus()获得焦点//以前竟然不知道 晕
===================================
如果不想某个按钮执行验证控件的检测,则可以把他的(按钮的)CausesValidation设置为false
===================================
sql datasource中updated后e.affectrows可以取得影响的行数,或者mp返回值
===================================
网易邮箱登录input的颜色样式
txtUsername.Attributes.Add("onMouseOver", "this.style.borderColor='#9ecc00'");
txtUsername.Attributes.Add("onMouseOut", "this.style.borderColor='#84a1bd'");
===================================
insertting时检测重复,e.cancel = true;然后return就可以保存状态
===================================
IIS中如果想有某文件夹的写权限可以设置network service用户权限。
====================================
sqlDataSource把CancelSelectOnNullParameter设为false则可以传入空的参数。
====================================
客户端获取asp.net的lable控件的值不要document.getElementbyID('').value;
而是应该document.getElementbyID('').innerText; or innerHTML
====================================
asp.net的控件比如textbox设置为readonly=true则用javascript添加他的value值,然后后台就取不到
====================================
在</head>之前增加<base target="_self" />,则
var a=window.showModalDialog("GetInv3.aspx",'a',"dialogWidth=1000px;dialogHeight=740px");
出来的窗体在自己内部跳转超链接。
====================================
根据数据改变Gridview的颜色:
        for (int i = 0; i < gvInvAlert.Rows.Count; i++)
        {
            if (gvInvAlert.Rows[i].Cells[7].Text == "报警")
            {
                gvInvAlert.Rows[i].ForeColor = System.Drawing.Color.Red;
            }
        }
但是此方法只对非模板列起作用,如果不想在edit时显示某列,可以设置其applyformatinEditmod为false
====================================
Request.ServerVariables["HTTP_USER_AGENT"];//获取浏览器信息
Request.ServerVariables["REMOTE_ADDR"];//获取ip地址
====================================
<input οnfοcus="if( this.value=='用 Google 搜索本站') {this.value='' };" id="gq" value="用 Google 搜索本站" type="text">
====================================
if string.IsNullOrEmpty()
====================================
    protected void gvStoreInit_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        //鼠标经过griadview时改变样式
        string sCSSover = "mosovTR";
        string sCSSout = "mosoutTR";
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Attributes.Add("onmouseover", "this.className = '" + sCSSover + "'");
            e.Row.Attributes.Add("onmouseout", "this.className = '" + sCSSout + "'");
        }
    }
====================================
    public class JavaScriptConstant
    {
        internal const string jsClickAndDoubleClick = @"<script type=""text/javascript"">
        //<![CDATA[
        var isDoubleClick = false;
        function yy_RowClick(id)
        {
            setTimeout(""yy_RowClickTimeout('""+id+""')"", 300);
        }
        function yy_RowClickTimeout(id)
        {
            if (isDoubleClick == false)
            {
                // 执行ID所指按钮的click事件
                document.getElementById(id).click();
            }
            isDoubleClick = true;
        }
        function yy_RowDoubleClick(id)
        {
            if (isDoubleClick == true)
            {
                // 执行ID所指按钮的click事件
                document.getElementById(id).click();
            }
            isDoubleClick = true;
        }
        //]]>
        </script>";
    }
=======================================

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值