首页 新闻 会员 周边

如何在后台点击事件中做POST提交

0
[待解决问题]
  能不能在A页面的后台cs文件,写提交然后POST到另一个页面,并打开那个页面?

比如:A.aspx.cs文件中有个click事件,里面有个方法,就是POST数据到B.aspx页面上去,并打开B.aspx页,

B页面会接收POST过来的数据,然后做相应的操作

有没有办法做到?

跪求解决的方法

补充一下:

是在后台方法中做POST,不是前台html 加from

fx2010的主页 fx2010 | 初学一级 | 园豆:200
提问于:2011-06-10 10:55
< >
分享
所有回答(1)
0

页面A:  

 protected void Button1_Click(object sender, EventArgs e)
        {
            RemotePost m = new RemotePost();
            m.Url = "B.aspx";
            m.Add("para1", "123456");
            m.Add("para2", "0001");
            m.Post();
        }

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

牦牛 | 园豆:218 (菜鸟二级) | 2011-06-10 12:06
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册