惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

爱范儿
爱范儿
WordPress大学
WordPress大学
C
Check Point Blog
GbyAI
GbyAI
U
Unit 42
Google DeepMind News
Google DeepMind News
B
Blog RSS Feed
Blog — PlanetScale
Blog — PlanetScale
J
Java Code Geeks
I
InfoQ
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Hugging Face - Blog
Hugging Face - Blog
Vercel News
Vercel News
博客园 - 【当耐特】
美团技术团队
小众软件
小众软件
S
SegmentFault 最新的问题
Jina AI
Jina AI
阮一峰的网络日志
阮一峰的网络日志
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
The Cloudflare Blog
Last Week in AI
Last Week in AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
Visual Studio Blog

博客园 - 日月星尘

转:web开发注意事项 iframe动适应大小 - 日月星尘 - 博客园 C#中Datatable转Excel 为FreeTextBox添加中文字体 使用Asp.net MVC源代码调试你的应用程序 jquery插件,240个 30个流行的jQuery Plugins jQuery常用技巧 jquery表单验证插件 jquery.form.js 支持文件上传~ 超强1000个jquery极品插件! 生成静态页核心代码 asp.net提高网站性能的方法 25个基于浏览器的HTML在线编辑器集合 SQL Server动态为表添加字段的方法 c#对象初始化顺序 通过/PAE打开Windows 2003/2000的大内存支持 JavaScript 对象设计 ASP.net初学者常用知识 ASP.NET应用程序设计的10大技巧
用代码的方式生成Form并提交表单 - 日月星尘 - 博客园
日月星尘 · 2009-08-17 · via 博客园 - 日月星尘

Posted on 2009-08-17 17:09  日月星尘  阅读(383)  评论()    收藏  举报

 /// <summary>
        
/// 创建Form HTML代码
        
/// </summary>
        
/// <param name="parma">需要添加的参数</param>
        
/// <param name="url">网关的Url</param>
        protected string GetForm(Dictionary<stringstring> parma, string url)
        {
            
string formItem = "<input type='hidden' name='{0}' value='{1}'>";
            StringBuilder html 
= new StringBuilder();

            html.AppendLine(

"<form name='Gateway' method='post'" + " action =" + url + ">");foreach (KeyValuePair<stringstring> item in parma)
            {
                html.AppendLine(
string.Format(formItem, item.Key, item.Value));
            }

            html.AppendLine(

"<input type='submit'id='submit' value='提交' style='display:none'/>");
            html.AppendLine(
"</form>");
            
//html.AppendLine("<script type='text/javascript'>window.document.Gateway.submit();</script>");
            html.AppendLine("<script type='text/javascript'>window.document.getElementById('submit').click();</script>");
            
return html.ToString();
        }