473,657 Members | 2,515 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do you process forms.submit on the server side?

Hello there,

I have the following code (written in Javascript) for posting of a form
on the client side:

....
var f2 = document.forms[SubmitForm];
f2.method = "post";
f2.submit();

When this goes to the server side, I tried to catch with:

public partial class Test : System.Web.UI.P age
{
protected void Page_Load(objec t sender, EventArgs e)
{
if (Page.IsPostBac k)
{
}
}
}

During the post, Page.IsPostBack is set to false.

What can I do to process the f2.submit() from the client side?

TIA

Nov 19 '05 #1
6 5660
Milkyway,

Is there a reason that you have to submit the form via javascript? If you
just use a regular ASP.NET submit button then Page.IsPostBack will be set to
true...

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"milkyway" <d0******@hotma il.com> wrote in message
news:11******** **************@ g49g2000cwa.goo glegroups.com.. .
Hello there,

I have the following code (written in Javascript) for posting of a form
on the client side:

....
var f2 = document.forms[SubmitForm];
f2.method = "post";
f2.submit();

When this goes to the server side, I tried to catch with:

public partial class Test : System.Web.UI.P age
{
protected void Page_Load(objec t sender, EventArgs e)
{
if (Page.IsPostBac k)
{
}
}
}

During the post, Page.IsPostBack is set to false.

What can I do to process the f2.submit() from the client side?

TIA

Nov 19 '05 #2
You probably have to call the __doSubmit(...) (or something like that)
method.

There is additional information that gets sent to the server that the site
may look for such as viewstate.

"milkyway" <d0******@hotma il.com> wrote in message
news:11******** **************@ g49g2000cwa.goo glegroups.com.. .
Hello there,

I have the following code (written in Javascript) for posting of a form
on the client side:

....
var f2 = document.forms[SubmitForm];
f2.method = "post";
f2.submit();

When this goes to the server side, I tried to catch with:

public partial class Test : System.Web.UI.P age
{
protected void Page_Load(objec t sender, EventArgs e)
{
if (Page.IsPostBac k)
{
}
}
}

During the post, Page.IsPostBack is set to false.

What can I do to process the f2.submit() from the client side?

TIA

Nov 19 '05 #3
Justin: I am using forms.submit() because my code is doing something
like the following

<INPUT onclick="alert( 'about to start'); process_table(' ShadFrmX',
'FValues');" type="button" value="Continue " >

Basically, I have a another form (called ShadFrmX) in my HTML that
starts out as being empty. This form is filled with the execution of
process_table with values to be sent to the server.

After the form is filled, then I call the code above (although all of
it is not present) to submit the form to the server.

The form submission works. The values do come over. I have seen it in
the debugger :-) and have been able to save them in a file.

The thing is, I don't know what event I should process or function
module I should use on the server side to when I do a forms.submit() on
the client side. Someone said to use page_load and a flag IsPostBack
but this does not work :-(

Will a submit button run the javascript code I have?

Since I am new to this programming area - I was wondering what would be
the right way to process this.

Peter: Is there a place where I can get more information (hopefully a
sample) on how to use doSubmit()?

Thanks for the help!

Nov 19 '05 #4
milkyway,

Yes, you can call the javascript from a submit button. Then the script will
run, the form will submit, and the Page.IsPostBack value will be true.

You will want to remove the forms.submit() from your javascript and add
"return true;" so that the button will still submit the form.

Then hook up a call to your javascript from the button in the page load of
the code behind like this:

MySubmitButton. Attributes.Add( "onclick",
"javascript:You rJavascriptFunc tionHere();")
--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche

"milkyway" <d0******@hotma il.com> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. .
Justin: I am using forms.submit() because my code is doing something
like the following

<INPUT onclick="alert( 'about to start'); process_table(' ShadFrmX',
'FValues');" type="button" value="Continue " >

Basically, I have a another form (called ShadFrmX) in my HTML that
starts out as being empty. This form is filled with the execution of
process_table with values to be sent to the server.

After the form is filled, then I call the code above (although all of
it is not present) to submit the form to the server.

The form submission works. The values do come over. I have seen it in
the debugger :-) and have been able to save them in a file.

The thing is, I don't know what event I should process or function
module I should use on the server side to when I do a forms.submit() on
the client side. Someone said to use page_load and a flag IsPostBack
but this does not work :-(

Will a submit button run the javascript code I have?

Since I am new to this programming area - I was wondering what would be
the right way to process this.

Peter: Is there a place where I can get more information (hopefully a
sample) on how to use doSubmit()?

Thanks for the help!

Nov 19 '05 #5
Hi Justin, Thanks for the pointer but I got things to work by using:

protected void Page_Load(objec t sender, EventArgs e)
{
if (Request.Form["Test"] != null)
{
//do processing with controls on the form
}
}

Is this something good/bad to? If so, why or why not?
Thanks!

Nov 19 '05 #6
milkyway,

That's a fine way to do it. It's really just a matter of how you like your
code structured/separated.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"milkyway" <d0******@hotma il.com> wrote in message
news:11******** **************@ g47g2000cwa.goo glegroups.com.. .
Hi Justin, Thanks for the pointer but I got things to work by using:

protected void Page_Load(objec t sender, EventArgs e)
{
if (Request.Form["Test"] != null)
{
//do processing with controls on the form
}
}

Is this something good/bad to? If so, why or why not?
Thanks!

Nov 19 '05 #7

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

Similar topics

1
1563
by: Dummy | last post by:
Hi, From the following web site http://docs.sun.com/source/816-6410-10/request.htm I have found how to access the elements of an HTML form from server-side Javascript. Using the "request" object built into the server the elements of the form appear under their name as a "dot field". For example "request.user_name" or "request.email". What I can't understand is how to deal with file uploads where the form
3
1591
by: Reetu | last post by:
Hi All, I have an html button on .aspx page. <INPUT class="sbttn" id="btnComplete0" onclick="onComplete ()" type="button" value="Mark Completed" name="btnComplete0"> When the user clicks on the html button the OnComplete function is called.
14
6291
by: Matt | last post by:
I want to know if ASP.NET Web Forms Validation Controls are Server-Side or Client-Side form validation? Since I think each validator control can select either 1) JavaScript based error dialog or 2) show the error message next to the control. For example, if the text field is empty with RequiredField Validator control, it can show the value in ControlToValidate property in two ways as I mentioned. Please advise. Thanks!
3
1812
by: ~J~ | last post by:
Hi everyone I'm positive this is possible, just never needed it until now and I don't have a clue where to start I have an XML document that is attached to an XSL style sheet, within this XSL there is some javascript commands that are attached to certain HTML controls What I want to do is when the user clicks on an HTML generated code (because I can't generate server-side controls in XSL), this runs a subroutine which is server-side ...
3
13488
by: Sileesh | last post by:
Hi I hope some one has an answer to this. I have a button in an aspx page . On server click of this button, i perform some operation. Once the operation is performed i want to close this window automatically. Pls help Sileesh
8
5076
by: Gert | last post by:
Hi, I have a form (server side) because of the filling of variables through the application. But now I need to post it to an url on submit. My .HTML form looks like this, but how to translate it to asp.net vb code? !--<FORM ACTION="/test/test.php" METHOD=POST>--> <form action="https://multipay.net/transaction/mpmain.php" method="post"> ....
10
2042
by: Ben | last post by:
Hi, I made an application in classic asp (reservation of books and video stuffs for students) and want to migrate to asp.net. The user has to chose a date, then pushung on a submit button. The whole day is then displayed in cels of a table. The user has then to click in a cel representing a hour of the day and an object (book ..), and finally click on the submit button to insert that reservation in the database. My problem is: there...
9
2373
by: jazzslider | last post by:
I have a headache. I've done a LOT of research lately into XForms, and I am thoroughly convinced that a good implementation of this technology would help me immensely in converting my department's paper forms into interactive online systems. There are a couple of problems I'm facing that I'm hoping someone here could help with. Number one: browser support for XForms is pitiful, and I can't expect my target audience to download...
5
2260
by: =?Utf-8?B?dXNmaW5lY2F0cw==?= | last post by:
I'm new to asp.net. I'm trying to follow the tutorial walkthroughs and have got a few done. Now I'm doing the one about validating input, and I've run into some problems. In particular, I am watching very intermittent behavior of my ASP page. when I execute: protected void buttonSubmit_Click(object sender, EventArgs e) {
0
8421
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8325
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8844
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8742
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8518
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8621
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7354
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
2
1971
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1734
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.