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

postback simulating button click

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
11 13814

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
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
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

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
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
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

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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Matt | last post by:
I always see the term "postback" from ASP book, but I am not sure if I fully understand the meaning. Here's my understanding so far, please correct me if any mistakes. Here's a typical html...
2
by: Cindy | last post by:
Hi all you smarties out there, I'm having a little conundrum with my asp.net page Scenario: I have a form (asp.net) with no code behind (as yet). I have placed a javascript function on a...
1
by: Earl Teigrob | last post by:
I did a ton of searching to try and find a simple solution to this issue and finally wrote my own, which I am sharing with everyone. In my searching, I did find a very complete and robust solution at...
2
by: RAJ | last post by:
In our multi-tier application, we have several ASP.NET user controls which will update the same data source provided by middle tier logic. In this particular scenario we have one user control...
12
by: Rudy | last post by:
Hi, I need to make a request to a asp.net page using HttpWebRequest class and I need to trick this page into thinking it's a postback and a button was clicked. But the page doesn't handle the...
3
by: Martin | last post by:
Hi, I have created a composite control that has a number of standard asp.net controls on it that can themselves cause postbacks. What i need to do in my composite control is to determine which...
11
by: antonyliu2002 | last post by:
I know that this has been asked and answered thousands of times. As a matter of fact, I know that I need to say If Not Page.IsPostBack Then 'Do something End If for things that needs to be...
15
by: mc | last post by:
I'm writing an app for managing Task Lists, I'm trying to add some controls to a form that I can use to link tasks, my original intention was to: - Add two list boxes, one listing "all Tasks"...
5
by: Bjorn Sagbakken | last post by:
Hello I have just migrated from VS 2003 to VS 2005, and .NET framework 1.1 to 2.0 I am at the end of debugging and fixing stuff. Now there is one error I just cannot find a solution to: On...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.