<form action="http://aaaaaa.hiaaa/aaa.php" method=post>
<INPUT type=radio value=4 name=piao checked> 
<INPUT type=submit value=提交 name=Submit>
</FORM>用JS实现了自动表单的提交现在想用C# 模拟把表单的内容提交到http://aaaaaa.hiaaa/aaa.php这个页面,不知道该怎么办
再往上找到的都是类似于http://aaaaaa.hiaaa/aaa.php?value=4这种类型的
现在想把radio里面的内容提交,高手帮忙

解决方案 »

  1.   


    //Post方法使用类,用于在ASP.NET中进行Post传值
    //
    /*使用方法:
    声明: RemotePost myremotepost =  new RemotePost();
    传值目标: myremotepost.Url = "Post传值接受页面.aspx";
    加入一个参数: myremotepost.Add("a","11");
    加入另一个一个参数: myremotepost.Add("b","100");
    传出: myremotepost.Post(); */using System;
    using System.Web;
    namespace ThinkBank.Libs.Command
    { public class PostLib
    {
    private System.Collections.Specialized.NameValueCollection Inputs = new System.Collections.Specialized.NameValueCollection();
    public string Url = "";
    public string Method = "post";
    public string FormName = "form1";

    public void Add(string name,string value)
    {
    Inputs.Add(name,value);
    }

    public void Post()
    {
    System.Web.HttpContext.Current.Response.Clear(); System.Web.HttpContext.Current.Response.Write("<html><head>");

    System.Web.HttpContext.Current.Response.Write(string.Format("</head><body onload=\"document.{0}.submit()\">",FormName));
    System.Web.HttpContext.Current.Response.Write(string.Format("<form name=\"{0}\" method=\"{1}\" action=\"{2}\" >",FormName,Method,Url));
    for(int i=0;i< Inputs.Keys.Count;i++)
    {
    System.Web.HttpContext.Current.Response.Write(string.Format("<input name=\"{0}\" type=\"hidden\" value=\"{1}\">",Inputs.Keys[i],Inputs[Inputs.Keys[i]]));
    }
    System.Web.HttpContext.Current.Response.Write("</form>");
    System.Web.HttpContext.Current.Response.Write("</body></html>"); System.Web.HttpContext.Current.Response.End();
    }
    }
    }