ASP.net 操作ログ採取 ボタン等

○基底クラス作成

    /// 
    /// ログ採取などの共通処理
    /// 
    public class baseBasePage : System.Web.UI.Page
    {
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            if (!IsPostBack)
            {                
                putLog(this.GetType().Name + " 初回表示");
            }
        }

        public override void RegisterRequiresRaiseEvent(System.Web.UI.IPostBackEventHandler control)
        {
            string str = string.Empty;

            if (control.GetType().Equals(typeof(Button)))
            {
                Button ctl = (Button)control;
                str += "ID=" + ctl.ID + " Txt=" + ctl.Text;
            }

            if (str != string.Empty)
            {
                str = this.GetType().Name + " - ■■■" + str + " (" + control.GetType().ToString() + ")";
                putLog(str);
            }

            base.RegisterRequiresRaiseEvent(control);
        }

        protected override void RaisePostBackEvent(System.Web.UI.IPostBackEventHandler sourceControl, string eventArgument)
        {
            string str = string.Empty;

            if (sourceControl.GetType().Equals(typeof(LinkButton)))
            {
                LinkButton ctl = (LinkButton)sourceControl;
                str += "ID=" + ctl.ID + " Txt=" + ctl.Text;
            }

            if (str != string.Empty)
            {
                str = this.GetType().Name + " - ■■■" + str + " (" + sourceControl.GetType().ToString() + ")";
                putLog(str);
            }

            base.RaisePostBackEvent(sourceControl, eventArgument);
        }

        public override void ProcessRequest(HttpContext context)
        {
            string key = string.Empty;

            key = "__CALLBACKID";
            if (context.Request.Params[key] != null)
            {
                putLog(MethodBase.GetCurrentMethod(), "■■■" + key + "=" + context.Request.Params[key]);
            }

            System.Diagnostics.Debug.Print("■context.Rezuest.Params cnt=" + context.Request.Params.Count.ToString());
            foreach (string s in context.Request.Params.Keys)
            {
                System.Diagnostics.Debug.Print(s + "=" + context.Request.Params[s]);
            }

            base.ProcessRequest(context);
        }
    }

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です