void PostMe1(Object sender,EventArgs e){
RemotePost myremotepost = new RemotePost();
myremotepost.Url = "http://www.jigar.net/demo/HttpRequestDemoServer.aspx";
myremotepost.Add("field1","Tom");
myremotepost.Add("field2","Sawyer");
myremotepost.Post();
}
void PostMe2(Object sender,EventArgs e){
RemotePost myremotepost = new RemotePost();
myremotepost.Url = "http://www.jigar.net/demo/HttpRequestDemoServer.aspx";
myremotepost.Add("field1","Huckleberry");
myremotepost.Add("field2","Finn");
myremotepost.Post();
}
public class RemotePost{
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="\">",FormName));
System.Web.HttpContext.Current.Response.Write(string.Format("<form name="\" method="\" action="\">",FormName,Method,Url));
for(int i=0;i< Inputs.Keys.Count;i++){
System.Web.HttpContext.Current.Response.Write(string.Format("<input name="\" type="\" value="\">",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();
}
}
0 comments:
Post a Comment