473,394 Members | 1,806 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Programmatically submitting a form

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
Nov 7 '06 #1
6 3729
You do it on the client with a javascript call myForm.sibmit();

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
"David Veeneman" <dc*@nospam.comwrote in message
news:OL**************@TK2MSFTNGP02.phx.gbl...
>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

Nov 7 '06 #2
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" <RE**************************@mMvVpPsS.orgwrote in
message news:e1**************@TK2MSFTNGP02.phx.gbl...
You do it on the client with a javascript call myForm.sibmit();

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
"David Veeneman" <dc*@nospam.comwrote in message
news:OL**************@TK2MSFTNGP02.phx.gbl...
>>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


Nov 7 '06 #3
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.

Nov 7 '06 #4
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?

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
"David Veeneman" <dc*@nospam.comwrote in message
news:uY*************@TK2MSFTNGP04.phx.gbl...
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.

Nov 7 '06 #5
I think I found my answer--use WebClient.UploadValues(). See
http://www.thescripts.com/forum/thread213769.html.
Nov 7 '06 #6
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
Nov 7 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: J Krugman | last post by:
I have a form with a couple of submit buttons, plus a "pseudolink" that is also supposed to submit the form; the submitted form data feeds to a CGI script. The two submit buttons have the name...
2
by: Greg T | last post by:
Hi, I have a rather long form that I don't want people submitting unless they are absolutely sure they are ready. I figured the easiest way to prevent an accidental form submission by way of...
5
by: Don | last post by:
I have a need to submit a form, but don't need the user to click on a button. How do I do this? Is there some way, using JavaScript, to setup a <form> tag to do this? Thanks, Don ----==...
2
by: Jackal | last post by:
I have a form page(abc.aspx) that contains some fields need to be filled in before submitting, and the action of the form is "def.aspx". After peocessing the filled-in data, it'll return the...
1
by: Hello | last post by:
Scenario: A page creates a pop up and that pop up submits a form. Is there a way to detect whether the submitting was successful or not, so true/false could be passed to the parent window?
4
by: Super Steve | last post by:
I'm trying to write a little script that disables the submit button on a form, changes the text of the button, and then submits the form. Can anyone tell me why this works ok: <input...
3
by: kgbalaji1980 | last post by:
Hi all, i want the jscript coding for more than one form in one page and submitting the same . ie one parent form and one append button when we click that button one child form will display...
18
by: NavinM | last post by:
I have a couple of forms that are misbehaving in FireFox, but work fine in IE. when i do submit( with submit button) a javascript function validates all of the fields entered, and stops the...
1
by: dittu | last post by:
How to close the popup window when submitting the form? I have a sample.jsp. In that page one button is there. when button pressed, open popup window contains one "text box" and one " submit...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.