日期:2014-05-18 浏览次数:20444 次
/// <summary> /// 构造提交表单HTML数据 /// </summary> /// <param name="sParaTemp">请求参数数组</param> /// <param name="gateway">网关地址</param> /// <param name="strMethod">提交方式。两个值可选:post、get</param> /// <param name="strButtonValue">确认按钮显示文字</param> /// <returns>提交表单HTML文本</returns> public static string BuildFormHtml(SortedDictionary<string, string> sParaTemp, string gateway, string strMethod, string strButtonValue) { //待请求参数数组 Dictionary<string, string> dicPara = new Dictionary<string, string>(); dicPara = BuildRequestPara(sParaTemp); StringBuilder sbHtml = new StringBuilder(); sbHtml.Append("<form id='alipaysubmit' name='alipaysubmit' action='" + gateway + "_input_charset=" + _input_charset + "' method='" + strMethod.ToLower().Trim() + "'>"); foreach (KeyValuePair<string, string> temp in dicPara) { 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['alipaysubmit'].submit();</script>"); return sbHtml.ToString(); }