国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

實(shí)現(xiàn)aspx頁面中,獲得焦點(diǎn),高亮顯示,離開時(shí)恢復(fù) 效果(完整代碼)

2019-11-17 04:17:00
字體:
供稿:網(wǎng)友

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Webapplication1._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<html xmlns="<head runat="server">
    <title>Untitled Page</title>
    <style>
        .highlight
        {
            background-color: yellow;
            color: blue;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
   
<asp:textbox runat="server" ></asp:textbox>
    </div>
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    </form>
</body>
</html>

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
namespace WebApplication1
{
    public static class Assistant
    {
        public static void SetInputControlsHighlight(Control container, string className, bool onlyTextBoxes)
        {
            foreach (Control ctl in container.Controls)
            {
                if ((onlyTextBoxes && ctl is TextBox) || (!onlyTextBoxes && (ctl is TextBox || ctl is DropDownList || ctl is ListBox || ctl is CheckBox || ctl is RadioButton || ctl is RadioButtonList || ctl is CheckBoxList)))
                {
                    WebControl wctl = ctl as WebControl;
                    wctl.Attributes.Add("onfocus", string.Format(
                       "this.className = '{0}';", className));
                    wctl.Attributes.Add("onBlur", "this.className='';");
                }
                else
                {
                    if (ctl.Controls.Count > 0)
                        SetInputControlsHighlight(ctl, className, onlyTextBoxes);
                }
            }
        }
    }


}


using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace WebApplication1
{
    public partial class _Default : System.Web.UI.Page
    {
       
PRotected void Page_Load(object sender, EventArgs e)
        {
            Assistant.SetInputControlsHighlight(this, "highlight", false);
        }
    }
}
http://blog.csdn.net/metababy/archive/2009/04/14/4072424.aspx


發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 嘉义市| 通许县| 米林县| 鹤壁市| 南阳市| 永嘉县| 广水市| 呼图壁县| 万宁市| 新河县| 封开县| 米易县| 眉山市| 星子县| 大理市| 兴安县| 济南市| 介休市| 英超| 南郑县| 仙居县| 黄龙县| 米林县| 青河县| 桐乡市| 汾西县| 南昌市| 黄梅县| 盐亭县| 建德市| 浮梁县| 前郭尔| 特克斯县| 正定县| 石景山区| 天水市| 贺州市| 广水市| 枞阳县| 麻栗坡县| 区。|