合作联系微信: w6668263      合作联系电话:177-9238-7426     

构造form表单

        public static string BuildFormHtml(SortedDictionary<string, string> sParaTemp, string gateway, string strMethod, string strButtonValue)
        {


            StringBuilder sbHtml = new StringBuilder();

            sbHtml.Append("<form id='Buildform1' name='Buildform1' action='" + gateway + "' method='" + strMethod.ToLower().Trim() + "'>");

            foreach (KeyValuePair<string, string> temp in sParaTemp)
            {
                sbHtml.Append("<input type='hidden' name='" + temp.Key + "' value='" + temp.Value + "'/>");
            }

            //submit按钮控件请不要含有name属性
            sbHtml.Append("<input type='submit' value='" + strButtonValue + "' style='display:none;'></form>");

            sbHtml.Append("<script>document.forms['Buildform1'].submit();</script>");
            return sbHtml.ToString();
        }
            //待请求参数数组
            SortedDictionary<string, string> dicPara = new SortedDictionary<string, string>();
            dicPara.Add("userName", userNo);
            string html = BuildFormHtml(dicPara, "passBackDo.aspx", "post", "下一步");
            Response.Write(html);

posted on 2012-08-18 11:43  草率的龙果果  阅读(671)  评论(0编辑  收藏  举报

导航