Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How do you process forms.submit on the server side?

Reply
Thread Tools

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

 
 
milkyway
Guest
Posts: n/a
 
      10-05-2005
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.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack)
{
}
}
}

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

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

TIA

 
Reply With Quote
 
 
 
 
S. Justin Gengo
Guest
Posts: n/a
 
      10-05-2005
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" <> wrote in message
news: oups.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.Page
> {
> protected void Page_Load(object sender, EventArgs e)
> {
> if (Page.IsPostBack)
> {
> }
> }
> }
>
> During the post, Page.IsPostBack is set to false.
>
> What can I do to process the f2.submit() from the client side?
>
> TIA
>



 
Reply With Quote
 
 
 
 
Peter Rilling
Guest
Posts: n/a
 
      10-05-2005
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" <> wrote in message
news: oups.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.Page
> {
> protected void Page_Load(object sender, EventArgs e)
> {
> if (Page.IsPostBack)
> {
> }
> }
> }
>
> During the post, Page.IsPostBack is set to false.
>
> What can I do to process the f2.submit() from the client side?
>
> TIA
>



 
Reply With Quote
 
milkyway
Guest
Posts: n/a
 
      10-06-2005
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!

 
Reply With Quote
 
S. Justin Gengo
Guest
Posts: n/a
 
      10-06-2005
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:YourJavascriptFunctionHere();")


--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche

"milkyway" <> wrote in message
news: oups.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!
>



 
Reply With Quote
 
milkyway
Guest
Posts: n/a
 
      10-07-2005
Hi Justin, Thanks for the pointer but I got things to work by using:

protected void Page_Load(object 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!

 
Reply With Quote
 
S. Justin Gengo
Guest
Posts: n/a
 
      10-07-2005
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" <> wrote in message
news: oups.com...
> Hi Justin, Thanks for the pointer but I got things to work by using:
>
> protected void Page_Load(object 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!
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Process Cannot access file "file_name" because it is being used by another process Rithesh Pai ASP .Net 1 08-22-2005 03:02 PM
I want to do a process once per page process, but 'touch' all instances of my server control. Jason Kendall ASP .Net Web Controls 1 06-01-2005 07:06 PM
(Win32) Timing out a process while reading process' output? rtm Perl 0 09-27-2004 10:06 PM
A process serving application pool 'DefaultAppPool' exceeded time limits during start up. The process id was '216'. jack ASP .Net 0 08-01-2004 09:49 PM
Are all the signals read in the process should appear in the sensitivity list of the process? walala VHDL 3 09-09-2003 07:47 AM



Advertisments