日期:2014-05-17  浏览次数:20697 次

C#.net 动态生成的button按钮及回发处理的实现

1、后台生成input的button按钮

HtmlGenericControl control = new HtmlGenericControl("input");

control.Attributes.Add("type", "button");

control.Attributes.Add("onclick",Page.ClientScript.GetPostBackEventReference(this, "btnMyQuery")

写入到界面中

2、后台回发拦截与处理

            if (Page.IsPostBack)
            {
                //获得回发参数
                string eventArgument = Page.Request.Form["__EVENTARGUMENT"];
                if (!String.IsNullOrEmpty(eventArgument)
                    && eventArgument.Equals("btnMyQuery"))
                {
                    //执行您的回发处理代码
                }
            }