模拟Confirm的Web自定义控件

using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.Collections;
using System.Collections.Specialized;
 
namespace PublicControls
{
     ///
     /// MsgBoxControl 的摘要说明。
     ///
 
     public class MsgBoxControl : Control,IPostBackDataHandler,IPostBackEventHandler
     {
         #region 预定义
    
         #endregion
 
         #region 属性
        
         #endregion
 
         #region 事件/方法
 
         ///
         /// 获取回发的数据
         ///
         ///
         ///
         ///
         public bool LoadPostData(String postDataKey, NameValueCollection values)
         {
 
            return false;       
         }
 
         ///
         /// 数据回发事件
         ///
         public void RaisePostDataChangedEvent()
         {
 
         }
 
         ///
         /// 回送事件
         ///
         ///
         public void RaisePostBackEvent(string e)
         {
 
         }
 
         ///
         /// 输出预处理
         ///
         ///
         protected override void OnPreRender(EventArgs e)
         {
             
         }
        
         ///
         /// 添加控件方法,该方法为指定控件添加onclick属性
         ///
         ///LinkButton 控件对象
         /// 提示信息
         public void AddAttributes(System.Web.UI.WebControls.LinkButton button,string msg)
         {
              button.Attributes.Add("onclick","return onformsubmit(this,'"+msg+"')");
         }
 
         ///
         /// 添加控件方法,该方法为指定控件添加onclick属性
         ///
         ///Button 控件对象
         /// 提示信息
         public void AddAttributes(System.Web.UI.WebControls.Button button,string msg)
         {
              button.Attributes.Add("onclick","return onformsubmit(this,'"+msg+"')");
         }
 
         #endregion
 
         #region 输出
         ///
         /// 将此控件呈现给指定的输出参数。
         ///
         /// 要写出到的 HTML 编写器
         protected override void Render(HtmlTextWriter output)
         {
              string View=ViewString();
 
              output.Write(View);
         }
         #endregion
 
         #region 其他函数
         ///
         /// 输出字符串
         ///
         ///
         string ViewString()
         {
              string view="";
              view+="/n";
 
 
              view+="
/n";
              view+="/n";
              view+="0 /n";
              view+="r
/n";
              view+="[ 确定]   [取消]/n";
              view+="/n";
              view+="
/n";
              return view;
         }
         #endregion
     }
}
 

你可能感兴趣的:(.net技术文章)