A
Alhambra Eidos Kiquenet
Hi misters,
I want to submit form in a console application to simulate user click
button to submit in browser
There are controls in page. Four TextBoxs and a Button (type submit).
And i have registered an event for button to handle the request:
void button_Click(object sender, EventArgs e)
{
Response.Write(userName.Text); //or do something
}
We can input data in TextBoxs, then click the button to submit it. The web
application will process the request
What i want to do is do it in an application.(see code below)
static void Main(string[] args)
{
string url = "http://localhost/contact.aspx";
WebClient client = new WebClient();
client.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
NameValueCollection values = new NameValueCollection();
values.Add("userName","xxx");
values.Add("email","xxx");
values.Add("company","xxx");
values.Add("comments","xxx");
values.Add("bSend","send");
byte[] r = client.UploadValues(url, "post", values);
}
But the application only fire the Page_Load event and doesn't raise the
Button.Click event.
any suggestions?
thanks in advance, any help will be very appreciated, regards.
I want to submit form in a console application to simulate user click
button to submit in browser
There are controls in page. Four TextBoxs and a Button (type submit).
And i have registered an event for button to handle the request:
void button_Click(object sender, EventArgs e)
{
Response.Write(userName.Text); //or do something
}
We can input data in TextBoxs, then click the button to submit it. The web
application will process the request
What i want to do is do it in an application.(see code below)
static void Main(string[] args)
{
string url = "http://localhost/contact.aspx";
WebClient client = new WebClient();
client.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
NameValueCollection values = new NameValueCollection();
values.Add("userName","xxx");
values.Add("email","xxx");
values.Add("company","xxx");
values.Add("comments","xxx");
values.Add("bSend","send");
byte[] r = client.UploadValues(url, "post", values);
}
But the application only fire the Page_Load event and doesn't raise the
Button.Click event.
any suggestions?
thanks in advance, any help will be very appreciated, regards.