By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,710 Members | 1,613 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,710 IT Pros & Developers. It's quick & easy.

postback simulating button click

P: n/a
CW
I have message entry screen that's causing me a bit of an issue. At the
moment, there are 2 buttons, one is used to send message to another user
(btnSend) and another is used to send messages to all users (btnSendAll).

When user hits enter, I also simulate the effect of clicking button
(btnSend). However, what I found btnSend doesn't fire (unless I click on the
button).

The postback function I call is as follows:
function __doPostBack(eventTarget, eventArgument)
{
var theform;
if (window.navigator.appName.toLowerCase().indexOf("n etscape") > -1)
{
theform = document.forms["Form1"];
}
else
{
theform = document.Form1;
}
theform.submit();
}

The script used to cause a postback is as follows:
<script language="javascript">
var mykey;
var posted=false;

if (window.Event){
document.captureEvents(Event.KEYDOWN);
}

document.onkeydown = myKeyDown;

function myKeyDown(e){

if (window.Event){
mykey = e.which;
}
else{
mykey = event.keyCode;
}
//alert(mykey);
if ((mykey==13) && (posted==false))
{
posted=true;
__doPostBack('btnSend:','onclick');
}

}
</script>
I think my problem is either not specifying eventTarget or eventArgument
correctly. Can someone please give a pointer on this.

Many thanx
Nov 18 '05 #1
Share this Question
Share on Google+
11 Replies


P: n/a

Hi CW,

I don't understand the requirement to catch the postback event on the client
side. Anyway, what you can try is to "click" on the button like this inside
the myKeyDown manually:
bntSend.click();

Define your button as a submit button, then it will automatically postback
and you don't have to catch the postback event. In any case, why don't you
use an asp:button?

Hope this helps,

Ethem

"CW" wrote:
I have message entry screen that's causing me a bit of an issue. At the
moment, there are 2 buttons, one is used to send message to another user
(btnSend) and another is used to send messages to all users (btnSendAll).

When user hits enter, I also simulate the effect of clicking button
(btnSend). However, what I found btnSend doesn't fire (unless I click on the
button).

The postback function I call is as follows:
function __doPostBack(eventTarget, eventArgument)
{
var theform;
if (window.navigator.appName.toLowerCase().indexOf("n etscape") > -1)
{
theform = document.forms["Form1"];
}
else
{
theform = document.Form1;
}
theform.submit();
}

The script used to cause a postback is as follows:
<script language="javascript">
var mykey;
var posted=false;

if (window.Event){
document.captureEvents(Event.KEYDOWN);
}

document.onkeydown = myKeyDown;

function myKeyDown(e){

if (window.Event){
mykey = e.which;
}
else{
mykey = event.keyCode;
}
//alert(mykey);
if ((mykey==13) && (posted==false))
{
posted=true;
__doPostBack('btnSend:','onclick');
}

}
</script>
I think my problem is either not specifying eventTarget or eventArgument
correctly. Can someone please give a pointer on this.

Many thanx

Nov 18 '05 #2

P: n/a
Hi CW,

Are you wanting to provide a function just like the "Default Button" in
winform application? If so, generally we can just add the "onkeydown"
script for the entryfield where the user will enter messages before he
submit.
Here are some former threads in the newsgroup discussing on this qustion,
you may have a look:

http://groups.google.com/groups?hl=e...2988%40cpmsftn
gxa10.phx.gbl&rnum=6&prev=/groups%3Fq%3Dasp.net%2Bdefault%2Bbutton%2Bsteven%
2Bcheng%26hl%3Den

http://groups.google.com/groups?hl=e...1992%40cpmsftn
gxa07.phx.gbl&rnum=8&prev=/groups%3Fq%3Dasp.net%2Bdefault%2Bbutton%2Bsteven%
2Bcheng%26hl%3Den

Hope helps. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #3

P: n/a
CW
They are asp.net buttons actually.

I need to catch enter so that it would have the same behaviour on different
browsers, not just IE.

btnSend.click works on IE, but does not work on Netscape or Mozilla.

Thanx
"Ethem Azun" <Et*******@discussions.microsoft.com> wrote in message
news:6A**********************************@microsof t.com...

Hi CW,

I don't understand the requirement to catch the postback event on the
client
side. Anyway, what you can try is to "click" on the button like this
inside
the myKeyDown manually:
bntSend.click();

Define your button as a submit button, then it will automatically postback
and you don't have to catch the postback event. In any case, why don't you
use an asp:button?

Hope this helps,

Ethem

"CW" wrote:
I have message entry screen that's causing me a bit of an issue. At the
moment, there are 2 buttons, one is used to send message to another user
(btnSend) and another is used to send messages to all users (btnSendAll).

When user hits enter, I also simulate the effect of clicking button
(btnSend). However, what I found btnSend doesn't fire (unless I click on
the
button).

The postback function I call is as follows:
function __doPostBack(eventTarget, eventArgument)
{
var theform;
if (window.navigator.appName.toLowerCase().indexOf("n etscape") > -1)
{
theform = document.forms["Form1"];
}
else
{
theform = document.Form1;
}
theform.submit();
}

The script used to cause a postback is as follows:
<script language="javascript">
var mykey;
var posted=false;

if (window.Event){
document.captureEvents(Event.KEYDOWN);
}

document.onkeydown = myKeyDown;

function myKeyDown(e){

if (window.Event){
mykey = e.which;
}
else{
mykey = event.keyCode;
}
//alert(mykey);
if ((mykey==13) && (posted==false))
{
posted=true;
__doPostBack('btnSend:','onclick');
}

}
</script>
I think my problem is either not specifying eventTarget or eventArgument
correctly. Can someone please give a pointer on this.

Many thanx

Nov 18 '05 #4

P: n/a

Hi,

I have Netscape 7.1 and the following does work (which is simply the
button.click() added to your code.). Are you sure that you are not doing
something wrong other than this? The aspnet button will be rendered as a
simple submit button.

<HTML>
<HEAD>
<title>Netscape</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
<script language="javascript">
var mykey;
var posted=false;
if (window.Event){
document.captureEvents(Event.KEYDOWN);
}
document.onkeydown = myKeyDown;
function myKeyDown(e){
if (window.Event){
mykey = e.which;
}
else{
mykey = event.keyCode;
}
//alert(mykey);
if ((mykey==13) && (posted==false))
{
posted=true;
this.Form1.butTest.click();
}
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:Button id="butTest" style="Z-INDEX: 101; LEFT: 56px; POSITION:
absolute; TOP: 32px" runat="server" Text="Button" Width="96px"></asp:Button>
</form>
</body>
</HTML>

"CW" wrote:
They are asp.net buttons actually.

I need to catch enter so that it would have the same behaviour on different
browsers, not just IE.

btnSend.click works on IE, but does not work on Netscape or Mozilla.

Thanx
"Ethem Azun" <Et*******@discussions.microsoft.com> wrote in message
news:6A**********************************@microsof t.com...

Hi CW,

I don't understand the requirement to catch the postback event on the
client
side. Anyway, what you can try is to "click" on the button like this
inside
the myKeyDown manually:
bntSend.click();

Define your button as a submit button, then it will automatically postback
and you don't have to catch the postback event. In any case, why don't you
use an asp:button?

Hope this helps,

Ethem

"CW" wrote:
I have message entry screen that's causing me a bit of an issue. At the
moment, there are 2 buttons, one is used to send message to another user
(btnSend) and another is used to send messages to all users (btnSendAll).

When user hits enter, I also simulate the effect of clicking button
(btnSend). However, what I found btnSend doesn't fire (unless I click on
the
button).

The postback function I call is as follows:
function __doPostBack(eventTarget, eventArgument)
{
var theform;
if (window.navigator.appName.toLowerCase().indexOf("n etscape") > -1)
{
theform = document.forms["Form1"];
}
else
{
theform = document.Form1;
}
theform.submit();
}

The script used to cause a postback is as follows:
<script language="javascript">
var mykey;
var posted=false;

if (window.Event){
document.captureEvents(Event.KEYDOWN);
}

document.onkeydown = myKeyDown;

function myKeyDown(e){

if (window.Event){
mykey = e.which;
}
else{
mykey = event.keyCode;
}
//alert(mykey);
if ((mykey==13) && (posted==false))
{
posted=true;
__doPostBack('btnSend:','onclick');
}

}
</script>
I think my problem is either not specifying eventTarget or eventArgument
correctly. Can someone please give a pointer on this.

Many thanx


Nov 18 '05 #5

P: n/a
CW
I think latest NN 7.x is fine. But the same javascript does not seem to fire
postback when run int NN 6.x and NN 4.x and Mozilla .9x.

Form1.btnSend.click() does not seem to be recognizable to them.

"Ethem Azun" <Et*******@discussions.microsoft.com> wrote in message
news:0A**********************************@microsof t.com...

Hi,

I have Netscape 7.1 and the following does work (which is simply the
button.click() added to your code.). Are you sure that you are not doing
something wrong other than this? The aspnet button will be rendered as a
simple submit button.

<HTML>
<HEAD>
<title>Netscape</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
<script language="javascript">
var mykey;
var posted=false;
if (window.Event){
document.captureEvents(Event.KEYDOWN);
}
document.onkeydown = myKeyDown;
function myKeyDown(e){
if (window.Event){
mykey = e.which;
}
else{
mykey = event.keyCode;
}
//alert(mykey);
if ((mykey==13) && (posted==false))
{
posted=true;
this.Form1.butTest.click();
}
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:Button id="butTest" style="Z-INDEX: 101; LEFT: 56px; POSITION:
absolute; TOP: 32px" runat="server" Text="Button"
Width="96px"></asp:Button>
</form>
</body>
</HTML>

"CW" wrote:
They are asp.net buttons actually.

I need to catch enter so that it would have the same behaviour on
different
browsers, not just IE.

btnSend.click works on IE, but does not work on Netscape or Mozilla.

Thanx
"Ethem Azun" <Et*******@discussions.microsoft.com> wrote in message
news:6A**********************************@microsof t.com...
>
> Hi CW,
>
> I don't understand the requirement to catch the postback event on the
> client
> side. Anyway, what you can try is to "click" on the button like this
> inside
> the myKeyDown manually:
> bntSend.click();
>
> Define your button as a submit button, then it will automatically
> postback
> and you don't have to catch the postback event. In any case, why don't
> you
> use an asp:button?
>
> Hope this helps,
>
> Ethem
>
> "CW" wrote:
>
>> I have message entry screen that's causing me a bit of an issue. At
>> the
>> moment, there are 2 buttons, one is used to send message to another
>> user
>> (btnSend) and another is used to send messages to all users
>> (btnSendAll).
>>
>> When user hits enter, I also simulate the effect of clicking button
>> (btnSend). However, what I found btnSend doesn't fire (unless I click
>> on
>> the
>> button).
>>
>> The postback function I call is as follows:
>> function __doPostBack(eventTarget, eventArgument)
>> {
>> var theform;
>> if (window.navigator.appName.toLowerCase().indexOf("n etscape")
>> > -1)
>> {
>> theform = document.forms["Form1"];
>> }
>> else
>> {
>> theform = document.Form1;
>> }
>> theform.submit();
>> }
>>
>> The script used to cause a postback is as follows:
>> <script language="javascript">
>> var mykey;
>> var posted=false;
>>
>> if (window.Event){
>> document.captureEvents(Event.KEYDOWN);
>> }
>>
>> document.onkeydown = myKeyDown;
>>
>> function myKeyDown(e){
>>
>> if (window.Event){
>> mykey = e.which;
>> }
>> else{
>> mykey = event.keyCode;
>> }
>> //alert(mykey);
>> if ((mykey==13) && (posted==false))
>> {
>> posted=true;
>> __doPostBack('btnSend:','onclick');
>> }
>>
>> }
>> </script>
>>
>>
>> I think my problem is either not specifying eventTarget or
>> eventArgument
>> correctly. Can someone please give a pointer on this.
>>
>> Many thanx
>>
>>
>>


Nov 18 '05 #6

P: n/a
How about
document.getElementById('btnSend').click();

"CW" wrote:
I think latest NN 7.x is fine. But the same javascript does not seem to fire
postback when run int NN 6.x and NN 4.x and Mozilla .9x.

Form1.btnSend.click() does not seem to be recognizable to them.

"Ethem Azun" <Et*******@discussions.microsoft.com> wrote in message
news:0A**********************************@microsof t.com...

Hi,

I have Netscape 7.1 and the following does work (which is simply the
button.click() added to your code.). Are you sure that you are not doing
something wrong other than this? The aspnet button will be rendered as a
simple submit button.

<HTML>
<HEAD>
<title>Netscape</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
<script language="javascript">
var mykey;
var posted=false;
if (window.Event){
document.captureEvents(Event.KEYDOWN);
}
document.onkeydown = myKeyDown;
function myKeyDown(e){
if (window.Event){
mykey = e.which;
}
else{
mykey = event.keyCode;
}
//alert(mykey);
if ((mykey==13) && (posted==false))
{
posted=true;
this.Form1.butTest.click();
}
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:Button id="butTest" style="Z-INDEX: 101; LEFT: 56px; POSITION:
absolute; TOP: 32px" runat="server" Text="Button"
Width="96px"></asp:Button>
</form>
</body>
</HTML>

"CW" wrote:
They are asp.net buttons actually.

I need to catch enter so that it would have the same behaviour on
different
browsers, not just IE.

btnSend.click works on IE, but does not work on Netscape or Mozilla.

Thanx
"Ethem Azun" <Et*******@discussions.microsoft.com> wrote in message
news:6A**********************************@microsof t.com...
>
> Hi CW,
>
> I don't understand the requirement to catch the postback event on the
> client
> side. Anyway, what you can try is to "click" on the button like this
> inside
> the myKeyDown manually:
> bntSend.click();
>
> Define your button as a submit button, then it will automatically
> postback
> and you don't have to catch the postback event. In any case, why don't
> you
> use an asp:button?
>
> Hope this helps,
>
> Ethem
>
> "CW" wrote:
>
>> I have message entry screen that's causing me a bit of an issue. At
>> the
>> moment, there are 2 buttons, one is used to send message to another
>> user
>> (btnSend) and another is used to send messages to all users
>> (btnSendAll).
>>
>> When user hits enter, I also simulate the effect of clicking button
>> (btnSend). However, what I found btnSend doesn't fire (unless I click
>> on
>> the
>> button).
>>
>> The postback function I call is as follows:
>> function __doPostBack(eventTarget, eventArgument)
>> {
>> var theform;
>> if (window.navigator.appName.toLowerCase().indexOf("n etscape")
>> > -1)
>> {
>> theform = document.forms["Form1"];
>> }
>> else
>> {
>> theform = document.Form1;
>> }
>> theform.submit();
>> }
>>
>> The script used to cause a postback is as follows:
>> <script language="javascript">
>> var mykey;
>> var posted=false;
>>
>> if (window.Event){
>> document.captureEvents(Event.KEYDOWN);
>> }
>>
>> document.onkeydown = myKeyDown;
>>
>> function myKeyDown(e){
>>
>> if (window.Event){
>> mykey = e.which;
>> }
>> else{
>> mykey = event.keyCode;
>> }
>> //alert(mykey);
>> if ((mykey==13) && (posted==false))
>> {
>> posted=true;
>> __doPostBack('btnSend:','onclick');
>> }
>>
>> }
>> </script>
>>
>>
>> I think my problem is either not specifying eventTarget or
>> eventArgument
>> correctly. Can someone please give a pointer on this.
>>
>> Many thanx
>>
>>
>>


Nov 18 '05 #7

P: n/a

or
document.forms["Form1"].bntSend.click()
or even
document.forms[0].bntSend.click() ?

it quite weird if they don't work either. Can you take a look at your html
output to see the id of the button if the ones above don't work?

"Jeremy Davis" wrote:
How about
document.getElementById('btnSend').click();

"CW" wrote:
I think latest NN 7.x is fine. But the same javascript does not seem to fire
postback when run int NN 6.x and NN 4.x and Mozilla .9x.

Form1.btnSend.click() does not seem to be recognizable to them.

"Ethem Azun" <Et*******@discussions.microsoft.com> wrote in message
news:0A**********************************@microsof t.com...

Hi,

I have Netscape 7.1 and the following does work (which is simply the
button.click() added to your code.). Are you sure that you are not doing
something wrong other than this? The aspnet button will be rendered as a
simple submit button.

<HTML>
<HEAD>
<title>Netscape</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
<script language="javascript">
var mykey;
var posted=false;
if (window.Event){
document.captureEvents(Event.KEYDOWN);
}
document.onkeydown = myKeyDown;
function myKeyDown(e){
if (window.Event){
mykey = e.which;
}
else{
mykey = event.keyCode;
}
//alert(mykey);
if ((mykey==13) && (posted==false))
{
posted=true;
this.Form1.butTest.click();
}
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:Button id="butTest" style="Z-INDEX: 101; LEFT: 56px; POSITION:
absolute; TOP: 32px" runat="server" Text="Button"
Width="96px"></asp:Button>
</form>
</body>
</HTML>

"CW" wrote:

> They are asp.net buttons actually.
>
> I need to catch enter so that it would have the same behaviour on
> different
> browsers, not just IE.
>
> btnSend.click works on IE, but does not work on Netscape or Mozilla.
>
> Thanx
>
>
> "Ethem Azun" <Et*******@discussions.microsoft.com> wrote in message
> news:6A**********************************@microsof t.com...
> >
> > Hi CW,
> >
> > I don't understand the requirement to catch the postback event on the
> > client
> > side. Anyway, what you can try is to "click" on the button like this
> > inside
> > the myKeyDown manually:
> > bntSend.click();
> >
> > Define your button as a submit button, then it will automatically
> > postback
> > and you don't have to catch the postback event. In any case, why don't
> > you
> > use an asp:button?
> >
> > Hope this helps,
> >
> > Ethem
> >
> > "CW" wrote:
> >
> >> I have message entry screen that's causing me a bit of an issue. At
> >> the
> >> moment, there are 2 buttons, one is used to send message to another
> >> user
> >> (btnSend) and another is used to send messages to all users
> >> (btnSendAll).
> >>
> >> When user hits enter, I also simulate the effect of clicking button
> >> (btnSend). However, what I found btnSend doesn't fire (unless I click
> >> on
> >> the
> >> button).
> >>
> >> The postback function I call is as follows:
> >> function __doPostBack(eventTarget, eventArgument)
> >> {
> >> var theform;
> >> if (window.navigator.appName.toLowerCase().indexOf("n etscape")
> >> > -1)
> >> {
> >> theform = document.forms["Form1"];
> >> }
> >> else
> >> {
> >> theform = document.Form1;
> >> }
> >> theform.submit();
> >> }
> >>
> >> The script used to cause a postback is as follows:
> >> <script language="javascript">
> >> var mykey;
> >> var posted=false;
> >>
> >> if (window.Event){
> >> document.captureEvents(Event.KEYDOWN);
> >> }
> >>
> >> document.onkeydown = myKeyDown;
> >>
> >> function myKeyDown(e){
> >>
> >> if (window.Event){
> >> mykey = e.which;
> >> }
> >> else{
> >> mykey = event.keyCode;
> >> }
> >> //alert(mykey);
> >> if ((mykey==13) && (posted==false))
> >> {
> >> posted=true;
> >> __doPostBack('btnSend:','onclick');
> >> }
> >>
> >> }
> >> </script>
> >>
> >>
> >> I think my problem is either not specifying eventTarget or
> >> eventArgument
> >> correctly. Can someone please give a pointer on this.
> >>
> >> Many thanx
> >>
> >>
> >>
>
>
>


Nov 18 '05 #8

P: n/a
HI CW

check into this
on page load add this

Page.RegisterHiddenField("__EVENTTARGET",this.<def ault button that you
want>.ClientID);

I use this on all pages with the javascript

what happens is that by default the page button will be what you have
set in < >

when you post back the page will look at the __EVENTTARGET field to
know with control trigged the post back

"CW" <CW@nospam.com> wrote in message news:<Og**************@TK2MSFTNGP15.phx.gbl>...
I think latest NN 7.x is fine. But the same javascript does not seem to fire
postback when run int NN 6.x and NN 4.x and Mozilla .9x.

Form1.btnSend.click() does not seem to be recognizable to them.

"Ethem Azun" <Et*******@discussions.microsoft.com> wrote in message
news:0A**********************************@microsof t.com...

Hi,

I have Netscape 7.1 and the following does work (which is simply the
button.click() added to your code.). Are you sure that you are not doing
something wrong other than this? The aspnet button will be rendered as a
simple submit button.

<HTML>
<HEAD>
<title>Netscape</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
<script language="javascript">
var mykey;
var posted=false;
if (window.Event){
document.captureEvents(Event.KEYDOWN);
}
document.onkeydown = myKeyDown;
function myKeyDown(e){
if (window.Event){
mykey = e.which;
}
else{
mykey = event.keyCode;
}
//alert(mykey);
if ((mykey==13) && (posted==false))
{
posted=true;
this.Form1.butTest.click();
}
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:Button id="butTest" style="Z-INDEX: 101; LEFT: 56px; POSITION:
absolute; TOP: 32px" runat="server" Text="Button"
Width="96px"></asp:Button>
</form>
</body>
</HTML>

"CW" wrote:
They are asp.net buttons actually.

I need to catch enter so that it would have the same behaviour on
different
browsers, not just IE.

btnSend.click works on IE, but does not work on Netscape or Mozilla.

Thanx
"Ethem Azun" <Et*******@discussions.microsoft.com> wrote in message
news:6A**********************************@microsof t.com...
>
> Hi CW,
>
> I don't understand the requirement to catch the postback event on the
> client
> side. Anyway, what you can try is to "click" on the button like this
> inside
> the myKeyDown manually:
> bntSend.click();
>
> Define your button as a submit button, then it will automatically
> postback
> and you don't have to catch the postback event. In any case, why don't
> you
> use an asp:button?
>
> Hope this helps,
>
> Ethem
>
> "CW" wrote:
>
>> I have message entry screen that's causing me a bit of an issue. At
>> the
>> moment, there are 2 buttons, one is used to send message to another
>> user
>> (btnSend) and another is used to send messages to all users
>> (btnSendAll).
>>
>> When user hits enter, I also simulate the effect of clicking button
>> (btnSend). However, what I found btnSend doesn't fire (unless I click
>> on
>> the
>> button).
>>
>> The postback function I call is as follows:
>> function __doPostBack(eventTarget, eventArgument)
>> {
>> var theform;
>> if (window.navigator.appName.toLowerCase().indexOf("n etscape")
>> > -1)
>> {
>> theform = document.forms["Form1"];
>> }
>> else
>> {
>> theform = document.Form1;
>> }
>> theform.submit();
>> }
>>
>> The script used to cause a postback is as follows:
>> <script language="javascript">
>> var mykey;
>> var posted=false;
>>
>> if (window.Event){
>> document.captureEvents(Event.KEYDOWN);
>> }
>>
>> document.onkeydown = myKeyDown;
>>
>> function myKeyDown(e){
>>
>> if (window.Event){
>> mykey = e.which;
>> }
>> else{
>> mykey = event.keyCode;
>> }
>> //alert(mykey);
>> if ((mykey==13) && (posted==false))
>> {
>> posted=true;
>> __doPostBack('btnSend:','onclick');
>> }
>>
>> }
>> </script>
>>
>>
>> I think my problem is either not specifying eventTarget or
>> eventArgument
>> correctly. Can someone please give a pointer on this.
>>
>> Many thanx
>>
>>
>>

Nov 18 '05 #9

P: n/a
Hi CW,

I think you can have a try on Jeremy's suggestion that use the
document.getElementById method to locate the submit button object. I
suspect that the problem is the submit button object is not located. The
Submit button's click() simiulate method is implement in javascript1.0 so I
think it should be support by netscape's early version.

Also, here is another blog article maybe helpful:

#Setting the default Button for a TextBox in ASP.NET
http://weblogs.asp.net/rajbk/archive.../11/43023.aspx

Thanks.
Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #10

P: n/a
CW
Hi everyone

Thanks for all the suggestions and help. I managed to get it work after
abandoning button.click() method.

Eveutally, I was able to get button.click to work, however, I had to modify
the code to use document.Form1.button.click()
or document.forms["Form1"].button.click(). For some reason, not specifying
document specifier causes the code not to run on NS browsers.
"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:i9**************@cpmsftngxa10.phx.gbl...
Hi CW,

I think you can have a try on Jeremy's suggestion that use the
document.getElementById method to locate the submit button object. I
suspect that the problem is the submit button object is not located. The
Submit button's click() simiulate method is implement in javascript1.0 so
I
think it should be support by netscape's early version.

Also, here is another blog article maybe helpful:

#Setting the default Button for a TextBox in ASP.NET
http://weblogs.asp.net/rajbk/archive.../11/43023.aspx

Thanks.
Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #11

P: n/a
HI CW,

Thanks for your followup and I'm glad that you figured out the problem.
Have a nice day!
Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #12

This discussion thread is closed

Replies have been disabled for this discussion.