| } } public string labelString { get { return label.Text; } set { label.Text = value; } } public string textString { get { return textBox.Text; } set { textBox.Text = value; } } 6、 这一步需要重写 CreateChildControls() 方法,该方法会自动被调用,用来生成子控件。 protected override void CreateChildControls() { this.EnsureChildControls();//如果子控件没有创建,则创建 base.CreateChildControls ();//调用方法 CreateControls(); } 7、 将第一步的脚本存到一个常量中: private const string MOUSE_SCRIPT = //用来触发鼠标事件的脚本 "<script language=javascript>\n" + "var OldColor;\n" + "function ltmouseover(ctrl,color)\n" + //当鼠标移入时,调用该方法,ctrl为表格,color为要改变的颜色值 "{\n" + "OldColor = ctrl.style.backgroundColor;\n" + //记录下原来的文档背景颜色 "ctrl.style.color = ''''#ffffff'''';\n" +//将字体颜色改为白色 "ctrl.style.backgroundColor = color;\n" + //更改表格背景颜色 "}\n" + "function ltmouseout(ctrl)\n" + //鼠标移出时调用 ,参数同上 "{\n" + "ctrl.style.backgroundColor = OldColor;\n" + //还原背景颜色 "ctrl.style.color = ''''#000000'''';" + //将字体颜色还原成黑色 "}\n" + 上一页 [1] [2] [3] [4] [5] 下一页 |