Re: Postback from javascript

From: Shri (Shri_at_discussions.microsoft.com)
Date: 12/13/04


Date: Mon, 13 Dec 2004 07:41:04 -0800

You could simply do this:
document.formName.submit(); You won't have the overhead of calling the
overhead of calling the iterator on the 'forms' object (although its not
expensive).

- Shri

"Martin Eyles" wrote:

> Thanks All, It's working nicely now.
>
> ME
>
> --
> Martin Eyles
> martin.eyles@NOSPAM.bytronic.com
> "William F. Robertson, Jr." <theman_at_fdrsucks.com> wrote in message
> news:uFut9vf3EHA.2676@TK2MSFTNGP12.phx.gbl...
> > If you look carefully at the __doPostBack method that asp.net uses to post
> > back the page, you will see the functions sets two hidden text fields.
> The
> > hidden text fields are used to notify the processing page what control
> > caused the postback (for say a button click) and any parameters passed by
> > it.
> >
> > Since you requirement is only a post back occured not caring about what
> > caused the postback, you can just call the submit method on the form
> object.
> >
> > document.forms[0].submit();
> >
> > This is the same method Microsoft uses to submit the form, and it will
> > accomplish what you are trying to accomplish with minimal effort.
> >
> > bill
> >
> > "Martin Eyles" <martin.eyles@NOSPAM.bytronic.com> wrote in message
> > news:10recvipllkl965@corp.supernews.com...
> > > what should I put in the eventTarget and eventArgument variables? I
> can't
> > > use a part of the form, as the postback is coming from a script (called
> > from
> > > another window), not the form. Note, I am not too bothered about working
> > out
> > > what caused post back, just that postback has occured.
> > >
> > > ME
> > >
> > > --
> > > Martin Eyles
> > > martin.eyles@NOSPAM.bytronic.com
> > >
> > > "Kumar Reddi" <KumarReddi@REMOVETHIS.gmail.com> wrote...
> > > > Yeah, as William suggest, if you simply want to postback using
> > javascript,
> > > > use document.forms[0].submit();. Or if you want to find out which
> > control
> > > > caused the postback or to postback using a tradional non postback
> > control,
> > > > then you can use the __doPostBack(). You do not have to make asp.net
> > > > generate the code, you can simply paste the following code. Thats
> > exactly
> > > > what asp.net generate for you if you put linkbutton or whatever
> > > >
> > > > <!--
> > > >
> > > > function __doPostBack(eventTarget, eventArgument) {
> > > > var theform;
> > > > if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1)
> {
> > > > theform = document.forms["Form1"];
> > > > }
> > > > else {
> > > > theform = document.Form1;
> > > > }
> > > > theform.__EVENTTARGET.value = eventTarget.split("$").join(":");
> > > > theform.__EVENTARGUMENT.value = eventArgument;
> > > > alert(theform.__EVENTARGUMENT.value);
> > > > theform.submit();
> > > > }
> > > > // -->
> > > >
> > > > Also, for this code to work, you need to place the following two
> hidden
> > > html
> > > > controls on your form
> > > >
> > > > <input type="hidden" name="__EVENTTARGET" />
> > > > <input type="hidden" name="__EVENTARGUMENT" />
> > >
> > >
> >
> >
>
>
>