在web自定义控件!(在IDE面板上引用可以看到的!非.ascx的那种)通过属性控制起visiable属性? 在web自定义控件!(在IDE面板上引用可以看到的!非.ascx的那种)通过属性控制起visiable属性? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我做的一个项目里 很多地方都有5个按纽添加 修改 删除 取消 查询我现在照网上的例子写了个有上述5个按纽的自定义控件 生成DLL 在工具箱里拖到页面能显示出来!声明的事件也没问题但是 怎么通过设置属性 来控制这些按狃的VISIABLE 和 enable 属性就不知道怎么搞了小弟第一次写这玩意 各位大哥帮忙!!!!! using System;using System.Collections.Generic;using System.ComponentModel;using System.Text;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.HtmlControls;namespace MyControls{ [DefaultProperty("Text")] [ToolboxData("<{0}:SubmitButtons runat=server></{0}:SubmitButtons>")] public class SubmitButtons : WebControl,INamingContainer { private Button _btnAdd; private Button _btnEdit; private Button _btnDel; private Button _btnQuery; private Button _btnCancel; private bool _showAddButton = true; private bool _showEditButton = true; private bool _showDelButton = true; private bool _showQueryButton = false; private bool _showCancelButton = true; private Byte _buttonState = 0; public Byte ButtonState { get { return _buttonState; } set { _buttonState = value; } } private string _buttonsCss = "btn21"; [Description("获取和设置添加按纽的Visible属性")] public bool ShowAddButton { get { if (ViewState["ShowAddButton"] == null) return _showAddButton; return Convert.ToBoolean(ViewState["ShowAddButton"]); } set { ViewState["ShowAddButton"] = value; } } [Description("获取和设置修改按纽的Visible属性")] public bool ShowEditButton { get { if (ViewState["ShowEditButton"] == null) return _showEditButton; return Convert.ToBoolean(ViewState["ShowEditButton"]); } set { ViewState["ShowEditButton"] = value; } } [Description("获取和设置删除按纽的Visible属性")] public bool ShowDelButton { get { if (ViewState["ShowDelButton"] == null) return _showDelButton; return Convert.ToBoolean(ViewState["ShowDelButton"]); } set { ViewState["ShowDelButton"] = value; } } [Description("获取和设置查询按纽的Visible属性")] public bool ShowQueryButton { get { if (ViewState["ShowQueryButton"] == null) return _showQueryButton; return Convert.ToBoolean(ViewState["ShowQueryButton"]); } set { ViewState["ShowQueryButton"] = value; } } [Description("获取和设置取消按纽的Visible属性")] public bool ShowCancelButton { get { if (ViewState["ShowCancelButton"] == null) return _showCancelButton; return Convert.ToBoolean(ViewState["ShowCancelButton"]); } set { ViewState["ShowCancelButton"] = value; } } [Description("获取和设置所有Button的属性")] public string ButtonsCss { get { if(ViewState["ButtonsCss"] == null) return _buttonsCss ; return ViewState["ButtonsCss"].ToString() ; } set { ViewState["ButtonsCss"] = value ; } } [Description("点击添加按钮的事件")] public event EventHandler BtnAdd_OnClick; [Description("点击修改按钮的事件")] public event EventHandler BtnEdit_OnClick; [Description("点击删除按钮的事件")] public event EventHandler BtnDel_OnClick; [Description("点击查询按钮的事件")] public event EventHandler BtnQuery_OnClick; [Description("点击取消按钮的事件")] public event EventHandler BtnCancel_OnClick; public SubmitButtons() { InitControls(); } private void InitControls() { _btnAdd = new Button(); _btnAdd.Text = "添 加"; _btnAdd.CssClass = _buttonsCss; _btnEdit = new Button(); _btnEdit.Text = "修 改"; _btnEdit.CssClass = _buttonsCss; _btnDel = new Button(); _btnDel.Text = "删 除"; _btnDel.CssClass = _buttonsCss; _btnQuery = new Button(); _btnQuery.Text = "查 询"; _btnQuery.CssClass = _buttonsCss; _btnQuery.Visible = _showQueryButton; _btnCancel = new Button(); _btnCancel.Text = "取 消"; _btnCancel.CssClass = _buttonsCss; this.Controls.Add(_btnAdd); this.Controls.Add(_btnEdit); this.Controls.Add(_btnDel); this.Controls.Add(_btnQuery); this.Controls.Add(_btnCancel); this._btnAdd.Click += new EventHandler(this.btnAdd_Click); this._btnEdit.Click += new EventHandler(this.btnEdit_Click); this._btnDel.Click += new EventHandler(this.btnDel_Click); this._btnQuery.Click += new EventHandler(this.btnQuery_Click); this._btnCancel.Click += new EventHandler(this.btnCancel_Click); } protected override void RenderContents(HtmlTextWriter output) { this._btnDel.Attributes.Add("onclick", "return confirm('确实要删除吗?')"); this._btnAdd.RenderBeginTag(output); output.Write(" "); this._btnEdit.RenderBeginTag(output); output.Write(" "); this._btnDel.RenderBeginTag(output); output.Write(" "); this._btnQuery.RenderBeginTag(output); output.Write(" "); this._btnCancel.RenderBeginTag(output); } private void btnAdd_Click(object sender, EventArgs e) { EventArgs eventArgs = new EventArgs(); if (this.BtnAdd_OnClick != null) this.BtnAdd_OnClick(this._btnAdd, eventArgs); } private void btnEdit_Click(object sender, EventArgs e) { EventArgs eventArgs = new EventArgs(); if (this.BtnEdit_OnClick != null) this.BtnEdit_OnClick(this._btnEdit, eventArgs); } private void btnDel_Click(object sender, EventArgs e) { EventArgs eventArgs = new EventArgs(); if (this.BtnDel_OnClick != null) this.BtnDel_OnClick(this._btnDel, eventArgs); } private void btnQuery_Click(object sender, EventArgs e) { EventArgs eventArgs = new EventArgs(); if (this.BtnQuery_OnClick != null) this.BtnQuery_OnClick(this._btnQuery, eventArgs); } private void btnCancel_Click(object sender, EventArgs e) { EventArgs eventArgs = new EventArgs(); if (this.BtnCancel_OnClick != null) this.BtnCancel_OnClick(this._btnCancel, eventArgs); } }} ASP.NET中创建统计图的问题 text赋值问题! 怎样利用asp.net制作网页有焦点图新闻 |zyciis| 像这些选择尺码的,他们是怎么来保存数据的呢 如何用sql将“a,b,c” 这样的字段拆分,在线急等。。。。求高手指点 按钮执行两次,Page_Load里执行一次 再问用数据适配器向数据库插入数据问题 复合控件中包含DataGrid的例子 1个关于msgbox的菜问题 VS.Net2003的正式版,版本好应该是多少?我觉得那些不需要输入注册号的一定不是正式的! 紧急求助!!! 请问象腾讯网(qq.com)首页上soso搜索那块点击综合 网页 图片出来得效果如何做?
能显示出来!声明的事件也没问题但是 怎么通过设置属性 来控制这些按狃的VISIABLE 和 enable 属性就不知道怎么搞了小弟第一次写这玩意 各位大哥帮忙!!!!!
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;namespace MyControls
{
[DefaultProperty("Text")]
[ToolboxData("<{0}:SubmitButtons runat=server></{0}:SubmitButtons>")]
public class SubmitButtons : WebControl,INamingContainer
{
private Button _btnAdd;
private Button _btnEdit;
private Button _btnDel;
private Button _btnQuery;
private Button _btnCancel; private bool _showAddButton = true;
private bool _showEditButton = true;
private bool _showDelButton = true;
private bool _showQueryButton = false;
private bool _showCancelButton = true; private Byte _buttonState = 0; public Byte ButtonState
{
get { return _buttonState; }
set { _buttonState = value; }
} private string _buttonsCss = "btn21"; [Description("获取和设置添加按纽的Visible属性")]
public bool ShowAddButton
{
get
{
if (ViewState["ShowAddButton"] == null)
return _showAddButton; return Convert.ToBoolean(ViewState["ShowAddButton"]);
}
set
{
ViewState["ShowAddButton"] = value;
}
} [Description("获取和设置修改按纽的Visible属性")]
public bool ShowEditButton
{
get
{
if (ViewState["ShowEditButton"] == null)
return _showEditButton; return Convert.ToBoolean(ViewState["ShowEditButton"]);
}
set
{
ViewState["ShowEditButton"] = value;
}
} [Description("获取和设置删除按纽的Visible属性")]
public bool ShowDelButton
{
get
{
if (ViewState["ShowDelButton"] == null)
return _showDelButton; return Convert.ToBoolean(ViewState["ShowDelButton"]);
}
set
{
ViewState["ShowDelButton"] = value;
}
} [Description("获取和设置查询按纽的Visible属性")]
public bool ShowQueryButton
{
get
{
if (ViewState["ShowQueryButton"] == null)
return _showQueryButton; return Convert.ToBoolean(ViewState["ShowQueryButton"]);
}
set
{
ViewState["ShowQueryButton"] = value;
}
} [Description("获取和设置取消按纽的Visible属性")]
public bool ShowCancelButton
{
get
{
if (ViewState["ShowCancelButton"] == null)
return _showCancelButton; return Convert.ToBoolean(ViewState["ShowCancelButton"]);
}
set
{
ViewState["ShowCancelButton"] = value;
}
} [Description("获取和设置所有Button的属性")]
public string ButtonsCss
{
get
{
if(ViewState["ButtonsCss"] == null)
return _buttonsCss ; return ViewState["ButtonsCss"].ToString() ;
}
set
{
ViewState["ButtonsCss"] = value ;
}
}
[Description("点击添加按钮的事件")]
public event EventHandler BtnAdd_OnClick; [Description("点击修改按钮的事件")]
public event EventHandler BtnEdit_OnClick; [Description("点击删除按钮的事件")]
public event EventHandler BtnDel_OnClick; [Description("点击查询按钮的事件")]
public event EventHandler BtnQuery_OnClick; [Description("点击取消按钮的事件")]
public event EventHandler BtnCancel_OnClick; public SubmitButtons()
{
InitControls();
} private void InitControls()
{
_btnAdd = new Button();
_btnAdd.Text = "添 加";
_btnAdd.CssClass = _buttonsCss;
_btnEdit = new Button();
_btnEdit.Text = "修 改";
_btnEdit.CssClass = _buttonsCss; _btnDel = new Button();
_btnDel.Text = "删 除";
_btnDel.CssClass = _buttonsCss; _btnQuery = new Button();
_btnQuery.Text = "查 询";
_btnQuery.CssClass = _buttonsCss;
_btnQuery.Visible = _showQueryButton; _btnCancel = new Button();
_btnCancel.Text = "取 消";
_btnCancel.CssClass = _buttonsCss; this.Controls.Add(_btnAdd);
this.Controls.Add(_btnEdit);
this.Controls.Add(_btnDel);
this.Controls.Add(_btnQuery);
this.Controls.Add(_btnCancel); this._btnAdd.Click += new EventHandler(this.btnAdd_Click);
this._btnEdit.Click += new EventHandler(this.btnEdit_Click);
this._btnDel.Click += new EventHandler(this.btnDel_Click);
this._btnQuery.Click += new EventHandler(this.btnQuery_Click);
this._btnCancel.Click += new EventHandler(this.btnCancel_Click);
} protected override void RenderContents(HtmlTextWriter output)
{
this._btnDel.Attributes.Add("onclick", "return confirm('确实要删除吗?')");
this._btnAdd.RenderBeginTag(output); output.Write(" ");
this._btnEdit.RenderBeginTag(output); output.Write(" ");
this._btnDel.RenderBeginTag(output); output.Write(" ");
this._btnQuery.RenderBeginTag(output); output.Write(" ");
this._btnCancel.RenderBeginTag(output);
} private void btnAdd_Click(object sender, EventArgs e)
{
EventArgs eventArgs = new EventArgs();
if (this.BtnAdd_OnClick != null)
this.BtnAdd_OnClick(this._btnAdd, eventArgs);
} private void btnEdit_Click(object sender, EventArgs e)
{
EventArgs eventArgs = new EventArgs();
if (this.BtnEdit_OnClick != null)
this.BtnEdit_OnClick(this._btnEdit, eventArgs);
}
private void btnDel_Click(object sender, EventArgs e)
{
EventArgs eventArgs = new EventArgs();
if (this.BtnDel_OnClick != null)
this.BtnDel_OnClick(this._btnDel, eventArgs);
}
private void btnQuery_Click(object sender, EventArgs e)
{
EventArgs eventArgs = new EventArgs();
if (this.BtnQuery_OnClick != null)
this.BtnQuery_OnClick(this._btnQuery, eventArgs);
}
private void btnCancel_Click(object sender, EventArgs e)
{
EventArgs eventArgs = new EventArgs();
if (this.BtnCancel_OnClick != null)
this.BtnCancel_OnClick(this._btnCancel, eventArgs);
}
}
}