Programmatically submitting a form

  • Thread starter Thread starter David Veeneman
  • Start date Start date
D

David Veeneman

I am building a form in code that I need to submit programmatically. How do
I do it in ASP.NET?

I am building a page that will create an HTML form on the server. The user
won't see the page; its sole purpose is to create and submit the form. I
store the form in a string:

string s = "<form target='somesite' action='https://www.somesite.com
method='post'>"
+ "<input type='hidden' name='item_name' value='MyWidget'>"
+ <input type='hidden' name='item_number' value='MW1'>"
...
+ "</form>";

Now I need a code statement to submit the form. How do I do that in C# or
VB? Thanks.

David Veeneman
Foresight Systems
 
If you want to do it from .NET code (codebehind), you should take a look at:
Page.ClientScript.GetPostBackEventReference(XXXx, "YYYY");

might be what you're looking for...

Karl

--
http://www.openmymind.net/
http://www.codebetter.com/


Eliyahu Goldin said:
You do it on the client with a javascript call myForm.sibmit();

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


David Veeneman said:
I am building a form in code that I need to submit programmatically. How
do I do it in ASP.NET?

I am building a page that will create an HTML form on the server. The
user won't see the page; its sole purpose is to create and submit the
form. I store the form in a string:

string s = "<form target='somesite' action='https://www.somesite.com
method='post'>"
+ "<input type='hidden' name='item_name' value='MyWidget'>"
+ <input type='hidden' name='item_number' value='MW1'>"
...
+ "</form>";

Now I need a code statement to submit the form. How do I do that in C# or
VB? Thanks.

David Veeneman
Foresight Systems
 
Can it be done on the server? I'd rather not send this form to the client.
It has fields a hacker could use to defraud the site. Thanks again.
 
Where do you intend to run it? A web form usually runs in the client's
browser.

Do you mean the server application creates the form and submit it to another
server?
 
Create another sever contorl submit button in the new form created and call the click for the button
in the Buttons click u can write any code if u want.

eg:
cmdbutton_Click(Me, EventArgs.Empty)

EggHeadCafe.com - .NET Developer Portal of Choice
http://www.eggheadcafe.com
 
Back
Top