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);