473,396 Members | 2,039 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,396 software developers and data experts.

Postback from javascript

I am trying to get javascript to cause a page to post back. I have tried
calling _doPostBack from my script, but generates an error "object
expected". I think this is because the page's script doesn't contain the
method _doPostBack, which needs to be added by asp.net. How can I make
asp.net add this script?

Thanks,
ME

--
Martin Eyles
ma**********@NOSPAM.bytronic.com
Nov 19 '05 #1
21 24396
Hello Martin,

I believe asp.net automatically adds this as soon as you add a linkbutton
or some other control that can cause a postback. Regular Button controls
would not trigger asp.net framework to add the javascript postback code since
html by default supports posting the form without javascript intervention.

I'm not sure how to trick asp.net into adding this code except for adding
a dummy linkbutton and not setting the text property, which would make the
linkbutton not take any space or be invisible to the user...

i'm sure there are better ways to accomplish this as what i'm suggesting
is a work around.
-john
I am trying to get javascript to cause a page to post back. I have
tried calling _doPostBack from my script, but generates an error
"object expected". I think this is because the page's script doesn't
contain the method _doPostBack, which needs to be added by asp.net.
How can I make asp.net add this script?

Thanks,
ME

Nov 19 '05 #2
Page.GetPostBackEventReference(this);

will trigger generation of the javascript postback code. you might want to
write a control that supports client postbacks.

-- bruce (sqlwork.com)

"Martin Eyles" <ma**********@NOSPAM.bytronic.com> wrote in message
news:10*************@corp.supernews.com...
| I am trying to get javascript to cause a page to post back. I have tried
| calling _doPostBack from my script, but generates an error "object
| expected". I think this is because the page's script doesn't contain the
| method _doPostBack, which needs to be added by asp.net. How can I make
| asp.net add this script?
|
| Thanks,
| ME
|
| --
| Martin Eyles
| ma**********@NOSPAM.bytronic.com
|
|
Nov 19 '05 #3
Just submit the form.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.

"Martin Eyles" <ma**********@NOSPAM.bytronic.com> wrote in message
news:10*************@corp.supernews.com...
I am trying to get javascript to cause a page to post back. I have tried
calling _doPostBack from my script, but generates an error "object
expected". I think this is because the page's script doesn't contain the
method _doPostBack, which needs to be added by asp.net. How can I make
asp.net add this script?

Thanks,
ME

--
Martin Eyles
ma**********@NOSPAM.bytronic.com

Nov 19 '05 #4
thanks bruce for the insight.
Page.GetPostBackEventReference(this);

will trigger generation of the javascript postback code. you might
want to write a control that supports client postbacks.

Nov 19 '05 #5
I added a submit button, but this has not added the javascript method. It
did add an action of the form, pointing to the current page. Also, the
editor picked up the button was submit and added a value to the button
("Submit Query").

Any more ideas, Thanks, ME

--
Martin Eyles
ma**********@NOSPAM.bytronic.com

"john morales" <jmorales@NO_SPAM-gmail-R3M0VE_TH1S.com> wrote in message
news:67********************@msnews.microsoft.com.. .
Hello Martin,

I believe asp.net automatically adds this as soon as you add a linkbutton
or some other control that can cause a postback. Regular Button controls
would not trigger asp.net framework to add the javascript postback code since html by default supports posting the form without javascript intervention.

I'm not sure how to trick asp.net into adding this code except for adding
a dummy linkbutton and not setting the text property, which would make the
linkbutton not take any space or be invisible to the user...

i'm sure there are better ways to accomplish this as what i'm suggesting
is a work around.
-john
I am trying to get javascript to cause a page to post back. I have
tried calling _doPostBack from my script, but generates an error
"object expected". I think this is because the page's script doesn't
contain the method _doPostBack, which needs to be added by asp.net.
How can I make asp.net add this script?

Thanks,
ME


Nov 19 '05 #6
Page.GetPostBackEventReference(this); made an error in the task list (this
not declared). I changed this to the name of an input on the page, and the
error disappeared. Still, it didn't solve my problem.

Thanks anyway, ME

--
Martin Eyles
ma**********@NOSPAM.bytronic.com

"bruce barker" <no***********@safeco.com> wrote in message
news:O8**************@TK2MSFTNGP15.phx.gbl...
Page.GetPostBackEventReference(this);

will trigger generation of the javascript postback code. you might want to
write a control that supports client postbacks.

-- bruce (sqlwork.com)
"Martin Eyles" <ma**********@NOSPAM.bytronic.com> wrote in message
news:10*************@corp.supernews.com...
| I am trying to get javascript to cause a page to post back. I have tried
| calling _doPostBack from my script, but generates an error "object
| expected". I think this is because the page's script doesn't contain the
| method _doPostBack, which needs to be added by asp.net. How can I make
| asp.net add this script?
|
| Thanks,
| ME
|
| --
| Martin Eyles
| ma**********@NOSPAM.bytronic.com
|
|

Nov 19 '05 #7
I thought calling _doPostBack was how you submitted an asp.net form. Is
there something else I can call from javascript that will submit the form -
maybe using the DOM? (I have not posted a form from javascript before).

Thanks,
ME

--
Martin Eyles
ma**********@NOSPAM.bytronic.com

"Kevin Spencer" <ks******@takempis.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Just submit the form.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Neither a follower
nor a lender be.

"Martin Eyles" <ma**********@NOSPAM.bytronic.com> wrote in message
news:10*************@corp.supernews.com...
I am trying to get javascript to cause a page to post back. I have tried
calling _doPostBack from my script, but generates an error "object
expected". I think this is because the page's script doesn't contain the
method _doPostBack, which needs to be added by asp.net. How can I make
asp.net add this script?

Thanks,
ME

--
Martin Eyles
ma**********@NOSPAM.bytronic.com


Nov 19 '05 #8
javascript:

document.forms[0].submit();

That will submit the form back to the server.

bill
"Martin Eyles" <ma**********@NOSPAM.bytronic.com> wrote in message
news:10*************@corp.supernews.com...
I thought calling _doPostBack was how you submitted an asp.net form. Is
there something else I can call from javascript that will submit the form - maybe using the DOM? (I have not posted a form from javascript before).

Thanks,
ME

--
Martin Eyles
ma**********@NOSPAM.bytronic.com

"Kevin Spencer" <ks******@takempis.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Just submit the form.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Neither a follower
nor a lender be.

"Martin Eyles" <ma**********@NOSPAM.bytronic.com> wrote in message
news:10*************@corp.supernews.com...
I am trying to get javascript to cause a page to post back. I have tried calling _doPostBack from my script, but generates an error "object
expected". I think this is because the page's script doesn't contain the method _doPostBack, which needs to be added by asp.net. How can I make
asp.net add this script?

Thanks,
ME

--
Martin Eyles
ma**********@NOSPAM.bytronic.com



Nov 19 '05 #9
it must be a linkbutton not a submit button.

-john
I added a submit button, but this has not added the javascript method.
It did add an action of the form, pointing to the current page. Also,
the editor picked up the button was submit and added a value to the
button ("Submit Query").

Any more ideas, Thanks, ME

"john morales" <jmorales@NO_SPAM-gmail-R3M0VE_TH1S.com> wrote in
message news:67********************@msnews.microsoft.com.. .
Hello Martin,

I believe asp.net automatically adds this as soon as you add a
linkbutton or some other control that can cause a postback. Regular
Button controls would not trigger asp.net framework to add the
javascript postback code

since
html by default supports posting the form without javascript
intervention.

I'm not sure how to trick asp.net into adding this code except for
adding a dummy linkbutton and not setting the text property, which
would make the linkbutton not take any space or be invisible to the
user...

i'm sure there are better ways to accomplish this as what i'm
suggesting is a work around.

-john
I am trying to get javascript to cause a page to post back. I have
tried calling _doPostBack from my script, but generates an error
"object expected". I think this is because the page's script doesn't
contain the method _doPostBack, which needs to be added by asp.net.
How can I make asp.net add this script?

Thanks,
ME

Nov 19 '05 #10
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("n etscape") > -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" />
--
Kumar Reddi
http://kumarreddi.blogspot.com

"Martin Eyles" <ma**********@NOSPAM.bytronic.com> wrote in message
news:10*************@corp.supernews.com...
I thought calling _doPostBack was how you submitted an asp.net form. Is
there something else I can call from javascript that will submit the form - maybe using the DOM? (I have not posted a form from javascript before).

Thanks,
ME

--
Martin Eyles
ma**********@NOSPAM.bytronic.com

"Kevin Spencer" <ks******@takempis.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Just submit the form.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Neither a follower
nor a lender be.

"Martin Eyles" <ma**********@NOSPAM.bytronic.com> wrote in message
news:10*************@corp.supernews.com...
I am trying to get javascript to cause a page to post back. I have tried calling _doPostBack from my script, but generates an error "object
expected". I think this is because the page's script doesn't contain the method _doPostBack, which needs to be added by asp.net. How can I make
asp.net add this script?

Thanks,
ME

--
Martin Eyles
ma**********@NOSPAM.bytronic.com



Nov 19 '05 #11
A submit button submits a form. It doesn't need any JavaScript.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.

"Martin Eyles" <ma**********@NOSPAM.bytronic.com> wrote in message
news:10*************@corp.supernews.com...
I added a submit button, but this has not added the javascript method. It
did add an action of the form, pointing to the current page. Also, the
editor picked up the button was submit and added a value to the button
("Submit Query").

Any more ideas, Thanks, ME

--
Martin Eyles
ma**********@NOSPAM.bytronic.com

"john morales" <jmorales@NO_SPAM-gmail-R3M0VE_TH1S.com> wrote in message
news:67********************@msnews.microsoft.com.. .
Hello Martin,

I believe asp.net automatically adds this as soon as you add a linkbutton or some other control that can cause a postback. Regular Button controls
would not trigger asp.net framework to add the javascript postback code

since
html by default supports posting the form without javascript intervention.
I'm not sure how to trick asp.net into adding this code except for adding a dummy linkbutton and not setting the text property, which would make the linkbutton not take any space or be invisible to the user...

i'm sure there are better ways to accomplish this as what i'm suggesting
is a work around.
-john
I am trying to get javascript to cause a page to post back. I have
tried calling _doPostBack from my script, but generates an error
"object expected". I think this is because the page's script doesn't
contain the method _doPostBack, which needs to be added by asp.net.
How can I make asp.net add this script?

Thanks,
ME



Nov 19 '05 #12
yes i'm aware of that, i mentioned it in my earlier post, the reason i suggested
to use a linkbutton was specifically that it doesnt support submitting the
form by default, thus asp.net would add the postback javascript block.

The question was "how do i get asp.net to add this script" not "how do i
submit the form"

A submit button submits a form. It doesn't need any JavaScript.

"Martin Eyles" <ma**********@NOSPAM.bytronic.com> wrote in message
news:10*************@corp.supernews.com...
I added a submit button, but this has not added the javascript
method. It did add an action of the form, pointing to the current
page. Also, the editor picked up the button was submit and added a
value to the button ("Submit Query").

Any more ideas, Thanks, ME

--
Martin Eyles
ma**********@NOSPAM.bytronic.com
"john morales" <jmorales@NO_SPAM-gmail-R3M0VE_TH1S.com> wrote in
message news:67********************@msnews.microsoft.com.. .
Hello Martin,

I believe asp.net automatically adds this as soon as you add a
linkbutton
or some other control that can cause a postback. Regular Button
controls would not trigger asp.net framework to add the javascript
postback code

since
html by default supports posting the form without javascript
intervention.
I'm not sure how to trick asp.net into adding this code except for
adding
a dummy linkbutton and not setting the text property, which would
make
the
linkbutton not take any space or be invisible to the user...

i'm sure there are better ways to accomplish this as what i'm
suggesting is a work around.

-john

I am trying to get javascript to cause a page to post back. I have
tried calling _doPostBack from my script, but generates an error
"object expected". I think this is because the page's script
doesn't contain the method _doPostBack, which needs to be added by
asp.net. How can I make asp.net add this script?

Thanks,
ME

Nov 19 '05 #13
> The question was "how do i get asp.net to add this script" not "how do i
submit the form"
The question was how to create a PostBack. I suggested simply submitting the
form. You said that you added a submit button. A submit button submits a
form. No JavaScript necessary.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.

"john morales" <jmorales@NO_SPAM-gmail-R3M0VE_TH1S.com> wrote in message
news:70********************@msnews.microsoft.com.. . yes i'm aware of that, i mentioned it in my earlier post, the reason i suggested to use a linkbutton was specifically that it doesnt support submitting the
form by default, thus asp.net would add the postback javascript block.

The question was "how do i get asp.net to add this script" not "how do i
submit the form"

A submit button submits a form. It doesn't need any JavaScript.

"Martin Eyles" <ma**********@NOSPAM.bytronic.com> wrote in message
news:10*************@corp.supernews.com...
I added a submit button, but this has not added the javascript
method. It did add an action of the form, pointing to the current
page. Also, the editor picked up the button was submit and added a
value to the button ("Submit Query").

Any more ideas, Thanks, ME

--
Martin Eyles
ma**********@NOSPAM.bytronic.com
"john morales" <jmorales@NO_SPAM-gmail-R3M0VE_TH1S.com> wrote in
message news:67********************@msnews.microsoft.com.. .

Hello Martin,

I believe asp.net automatically adds this as soon as you add a

linkbutton
or some other control that can cause a postback. Regular Button
controls would not trigger asp.net framework to add the javascript
postback code

since

html by default supports posting the form without javascript

intervention.
I'm not sure how to trick asp.net into adding this code except for

adding
a dummy linkbutton and not setting the text property, which would
make

the
linkbutton not take any space or be invisible to the user...

i'm sure there are better ways to accomplish this as what i'm
suggesting is a work around.

-john

> I am trying to get javascript to cause a page to post back. I have
> tried calling _doPostBack from my script, but generates an error
> "object expected". I think this is because the page's script
> doesn't contain the method _doPostBack, which needs to be added by
> asp.net. How can I make asp.net add this script?
>
> Thanks,
> ME


Nov 19 '05 #14
Thanks,
In the end, I modified this slightly to get
document.getElementById("Form1").submit();
This works beautifully, posting back the form.
Just one other thing. If I use IsPostBack on the server side, will this be
detected as such? If not, what do I need to do?

ME

--
Martin Eyles
ma**********@NOSPAM.bytronic.com

"William F. Robertson, Jr." <theman_at_fdrsucks.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
javascript:

document.forms[0].submit();

That will submit the form back to the server.

bill
"Martin Eyles" <ma**********@NOSPAM.bytronic.com> wrote in message
news:10*************@corp.supernews.com...
I thought calling _doPostBack was how you submitted an asp.net form. Is
there something else I can call from javascript that will submit the

form -
maybe using the DOM? (I have not posted a form from javascript before).

Thanks,
ME

--
Martin Eyles
ma**********@NOSPAM.bytronic.com

"Kevin Spencer" <ks******@takempis.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Just submit the form.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Neither a follower
nor a lender be.

"Martin Eyles" <ma**********@NOSPAM.bytronic.com> wrote in message
news:10*************@corp.supernews.com...
> I am trying to get javascript to cause a page to post back. I have tried > calling _doPostBack from my script, but generates an error "object
> expected". I think this is because the page's script doesn't contain the > method _doPostBack, which needs to be added by asp.net. How can I make > asp.net add this script?
>
> Thanks,
> ME
>
> --
> Martin Eyles
> ma**********@NOSPAM.bytronic.com
>
>



Nov 19 '05 #15
Thanks guys, this has given me some insight into how the whole postback for
<asp:anything> items works, and how the objects can all be identified server
side. I took the suggestion from William in the end and did

document.getElementById("Form1").submit();

which does exactly what I want.

Thanks anyway,
ME

--
Martin Eyles
ma**********@NOSPAM.bytronic.com

"Kevin Spencer" <ks******@takempis.com> wrote in message
news:Od**************@tk2msftngp13.phx.gbl...
The question was "how do i get asp.net to add this script" not "how do i
submit the form"
The question was how to create a PostBack. I suggested simply submitting

the form. You said that you added a submit button. A submit button submits a
form. No JavaScript necessary.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Neither a follower
nor a lender be.

"john morales" <jmorales@NO_SPAM-gmail-R3M0VE_TH1S.com> wrote in message
news:70********************@msnews.microsoft.com.. .
yes i'm aware of that, i mentioned it in my earlier post, the reason i

suggested
to use a linkbutton was specifically that it doesnt support submitting the form by default, thus asp.net would add the postback javascript block.

The question was "how do i get asp.net to add this script" not "how do i
submit the form"

A submit button submits a form. It doesn't need any JavaScript.

"Martin Eyles" <ma**********@NOSPAM.bytronic.com> wrote in message
news:10*************@corp.supernews.com...

> I added a submit button, but this has not added the javascript
> method. It did add an action of the form, pointing to the current
> page. Also, the editor picked up the button was submit and added a
> value to the button ("Submit Query").
>
> Any more ideas, Thanks, ME
>
> --
> Martin Eyles
> ma**********@NOSPAM.bytronic.com
> "john morales" <jmorales@NO_SPAM-gmail-R3M0VE_TH1S.com> wrote in
> message news:67********************@msnews.microsoft.com.. .
>
>> Hello Martin,
>>
>> I believe asp.net automatically adds this as soon as you add a
>>
linkbutton

>> or some other control that can cause a postback. Regular Button
>> controls would not trigger asp.net framework to add the javascript
>> postback code
>>
> since
>
>> html by default supports posting the form without javascript
>>
intervention.

>> I'm not sure how to trick asp.net into adding this code except for
>>
adding

>> a dummy linkbutton and not setting the text property, which would
>> make
>>
the

>> linkbutton not take any space or be invisible to the user...
>>
>> i'm sure there are better ways to accomplish this as what i'm
>> suggesting is a work around.
>>
>> -john
>>
>>> I am trying to get javascript to cause a page to post back. I have
>>> tried calling _doPostBack from my script, but generates an error
>>> "object expected". I think this is because the page's script
>>> doesn't contain the method _doPostBack, which needs to be added by
>>> asp.net. How can I make asp.net add this script?
>>>
>>> Thanks,
>>> ME



Nov 19 '05 #16
Half answered my own question. the form submition does not get detected as a
post-back by the server. What am I doing wrong?

--
Martin Eyles
ma**********@NOSPAM.bytronic.com

"Martin Eyles" <ma**********@NOSPAM.bytronic.com> wrote...
In the end, I modified this slightly to get
document.getElementById("Form1").submit();
This works beautifully, posting back the form.
Just one other thing. If I use IsPostBack on the server side, will this
be detected as such? If not, what do I need to do?

"William F. Robertson, Jr." <theman_at_fdrsucks.com> wrote...
javascript:document.forms[0].submit();

That will submit the form back to the server.

"Martin Eyles" <ma**********@NOSPAM.bytronic.com> wrote...
I thought calling _doPostBack was how you submitted an asp.net
form. Is there something else I can call from javascript that will
submit the form - maybe using the DOM? (I have not posted a
form from javascript before).

"Kevin Spencer" <ks******@takempis.com> wrote...
> Just submit the form.
>
> "Martin Eyles" <ma**********@NOSPAM.bytronic.com> wrote...
> > I am trying to get javascript to cause a page to post back

Nov 19 '05 #17
Hello Martin,

try using inserting the javascript code Kumar suggested and calling the __doPostBack
javascript function.

-john
Half answered my own question. the form submition does not get
detected as a post-back by the server. What am I doing wrong?

"Martin Eyles" <ma**********@NOSPAM.bytronic.com> wrote...
In the end, I modified this slightly to get
document.getElementById("Form1").submit();
This works beautifully, posting back the form.
Just one other thing. If I use IsPostBack on the server side, will
this
be detected as such? If not, what do I need to do?
"William F. Robertson, Jr." <theman_at_fdrsucks.com> wrote...
javascript:document.forms[0].submit();

That will submit the form back to the server.

"Martin Eyles" <ma**********@NOSPAM.bytronic.com> wrote...

I thought calling _doPostBack was how you submitted an asp.net
form. Is there something else I can call from javascript that will
submit the form - maybe using the DOM? (I have not posted a
form from javascript before).
"Kevin Spencer" <ks******@takempis.com> wrote...

> Just submit the form.
>
> "Martin Eyles" <ma**********@NOSPAM.bytronic.com> wrote...
>
>> I am trying to get javascript to cause a page to post back
>>

Nov 19 '05 #18
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
ma**********@NOSPAM.bytronic.com

"Kumar Reddi" <Ku********@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("n etscape") > -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" />

Nov 19 '05 #19
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" <ma**********@NOSPAM.bytronic.com> wrote in message
news:10*************@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
ma**********@NOSPAM.bytronic.com

"Kumar Reddi" <Ku********@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("n etscape") > -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" />


Nov 19 '05 #20
Thanks All, It's working nicely now.

ME

--
Martin Eyles
ma**********@NOSPAM.bytronic.com
"William F. Robertson, Jr." <theman_at_fdrsucks.com> wrote in message
news:uF**************@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" <ma**********@NOSPAM.bytronic.com> wrote in message
news:10*************@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
ma**********@NOSPAM.bytronic.com

"Kumar Reddi" <Ku********@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("n etscape") > -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" />



Nov 19 '05 #21
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
ma**********@NOSPAM.bytronic.com
"William F. Robertson, Jr." <theman_at_fdrsucks.com> wrote in message
news:uF**************@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" <ma**********@NOSPAM.bytronic.com> wrote in message
news:10*************@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
ma**********@NOSPAM.bytronic.com

"Kumar Reddi" <Ku********@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("n etscape") > -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" />



Nov 19 '05 #22

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

Similar topics

1
by: Svein Terje Gaup | last post by:
When I try to validate my webpages on http://validator.w3.org the validation fails because of the auto-generated postback function: <script language="javascript"> <!-- function...
0
by: Thomas Due | last post by:
Hello, I am in the process of making my asp.net form to validate as xhtml 1.0 strict. So far I am doing well, but now I have a problem. The problem concerns specifically DropDownList and...
1
by: Angel | last post by:
I have a button, combo, and custom control that i created. When I click the button i want to set certain display properties of my custom control depending whats in the combo. I set those properties...
0
by: JoRo | last post by:
I found a great design template idea on this website http://www.csharphelp.com/archives2/archive383.html. But when I downloaded the code and tried to implement ControlsPage.aspx, I got a...
2
by: Bahman | last post by:
Hello! Except for dropdownlists, all other controls have lost their postback call. The default postback call runs all the time. What would be the more likely cause for this? Thank you for...
3
by: Darrel | last post by:
I have a page that lists a bunch of items. You can check each item and hit ADD to add these items to a record in the DB. This page has a dropDownList. When you select an item from the list, I...
7
by: Tony Girgenti | last post by:
Hello. I'm trying to undetrstand ASP.NET 2.0 and javascript. When i have a button and i click on it and i see the web broswer progress bar at the bottom do something, does that mean that there...
2
by: wildman | last post by:
RE: Gridview textbox has data check without postback.. javascript? I have a gridview with a textbox. I can set the textbox to autopostback and check for a value in a prerender event to decide if...
1
by: Jethro | last post by:
Hi all working on someone elses code ! I have a javascript call at the end of the <BODYtag, which sets up a calendar utility connected to an image button. This works fine. However there is a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
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
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,...

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.