I have the following code that attaches a Javascript confirm box to my
checkbox. When I select the checkbox, the window comes up fine, but it
never executes the XfertoDefault_Click function when I press the Yes button.
If I take off the Javascript event, the checkbox works fine.
XferToDefault.Attributes.Add("onclick", "return confirm('Are you sure you
want copy these entries?');")
<asp:CheckBox ID="XferToDefault" AutoPostBack="true"
OnCheckedChanged="XferToDefault_Click" runat="server"/>
If I change the checkbox to an ImageButton, it all works fine - the
Javascript window as well as going to the function after the Yes button is
pressed.
<asp:ImageButton ID="XferToDefault" OnClick="XferToDefault_Click"
ImageUrl="../../buttons/xfer.gif" runat="server"/>
Why doesn't the checkbox (or radiobutton) work?
Thanks,
Tom 12 2105
Tom,
Try
XferToDefault.Attributes.Add("onclick", "if(!confirm('Are you sure you want
copy these entries?')return;")
If it works, I can explain the reason.
Eliyahu
"tshad" <tf*@dslextreme.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl... I have the following code that attaches a Javascript confirm box to my checkbox. When I select the checkbox, the window comes up fine, but it never executes the XfertoDefault_Click function when I press the Yes
button. If I take off the Javascript event, the checkbox works fine.
XferToDefault.Attributes.Add("onclick", "return confirm('Are you sure you want copy these entries?');")
<asp:CheckBox ID="XferToDefault" AutoPostBack="true" OnCheckedChanged="XferToDefault_Click" runat="server"/>
If I change the checkbox to an ImageButton, it all works fine - the Javascript window as well as going to the function after the Yes button is pressed. <asp:ImageButton ID="XferToDefault" OnClick="XferToDefault_Click" ImageUrl="../../buttons/xfer.gif" runat="server"/>
Why doesn't the checkbox (or radiobutton) work?
Thanks,
Tom
"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:ui**************@tk2msftngp13.phx.gbl... Tom,
Try
XferToDefault.Attributes.Add("onclick", "if(!confirm('Are you sure you
want copy these entries?')return;")
I tried that, but there must be a problem with the Javascript. I don't get
the confirm box at all now, as well as not going to the function.
Tom If it works, I can explain the reason.
Eliyahu
"tshad" <tf*@dslextreme.com> wrote in message news:%2****************@TK2MSFTNGP09.phx.gbl... I have the following code that attaches a Javascript confirm box to my checkbox. When I select the checkbox, the window comes up fine, but it never executes the XfertoDefault_Click function when I press the Yes button. If I take off the Javascript event, the checkbox works fine.
XferToDefault.Attributes.Add("onclick", "return confirm('Are you sure
you want copy these entries?');")
<asp:CheckBox ID="XferToDefault" AutoPostBack="true" OnCheckedChanged="XferToDefault_Click" runat="server"/>
If I change the checkbox to an ImageButton, it all works fine - the Javascript window as well as going to the function after the Yes button
is pressed. <asp:ImageButton ID="XferToDefault" OnClick="XferToDefault_Click" ImageUrl="../../buttons/xfer.gif" runat="server"/>
Why doesn't the checkbox (or radiobutton) work?
Thanks,
Tom
One more bracket:
XferToDefault.Attributes.Add("onclick", "if(!confirm('Are you sure you want
copy these entries?'))return;")
--
Eliyahu
"tshad" <tf*@dslextreme.com> wrote in message
news:O5**************@tk2msftngp13.phx.gbl... "Eliyahu Goldin" <re*************@monarchmed.com> wrote in message news:ui**************@tk2msftngp13.phx.gbl... Tom,
Try
XferToDefault.Attributes.Add("onclick", "if(!confirm('Are you sure you want copy these entries?')return;")
I tried that, but there must be a problem with the Javascript. I don't
get the confirm box at all now, as well as not going to the function.
Tom
If it works, I can explain the reason.
Eliyahu
"tshad" <tf*@dslextreme.com> wrote in message news:%2****************@TK2MSFTNGP09.phx.gbl... I have the following code that attaches a Javascript confirm box to my checkbox. When I select the checkbox, the window comes up fine, but
it never executes the XfertoDefault_Click function when I press the Yes button. If I take off the Javascript event, the checkbox works fine.
XferToDefault.Attributes.Add("onclick", "return confirm('Are you sure you want copy these entries?');")
<asp:CheckBox ID="XferToDefault" AutoPostBack="true" OnCheckedChanged="XferToDefault_Click" runat="server"/>
If I change the checkbox to an ImageButton, it all works fine - the Javascript window as well as going to the function after the Yes
button is pressed. <asp:ImageButton ID="XferToDefault" OnClick="XferToDefault_Click" ImageUrl="../../buttons/xfer.gif" runat="server"/>
Why doesn't the checkbox (or radiobutton) work?
Thanks,
Tom
"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:eG**************@TK2MSFTNGP15.phx.gbl... One more bracket:
XferToDefault.Attributes.Add("onclick", "if(!confirm('Are you sure you
want copy these entries?'))return;")
That works fine now,
How come?
Why didn't the other one work if it worked with the asp:imageButton and
asp:linkbutton?
Thanks,
Tom
-- Eliyahu
"tshad" <tf*@dslextreme.com> wrote in message news:O5**************@tk2msftngp13.phx.gbl... "Eliyahu Goldin" <re*************@monarchmed.com> wrote in message news:ui**************@tk2msftngp13.phx.gbl... Tom,
Try
XferToDefault.Attributes.Add("onclick", "if(!confirm('Are you sure
you want copy these entries?')return;")
I tried that, but there must be a problem with the Javascript. I don't get the confirm box at all now, as well as not going to the function.
Tom
If it works, I can explain the reason.
Eliyahu
"tshad" <tf*@dslextreme.com> wrote in message news:%2****************@TK2MSFTNGP09.phx.gbl... > I have the following code that attaches a Javascript confirm box to
my > checkbox. When I select the checkbox, the window comes up fine, but it > never executes the XfertoDefault_Click function when I press the Yes button. > If I take off the Javascript event, the checkbox works fine. > > XferToDefault.Attributes.Add("onclick", "return confirm('Are you
sure you > want copy these entries?');") > > <asp:CheckBox ID="XferToDefault" AutoPostBack="true" > OnCheckedChanged="XferToDefault_Click" runat="server"/> > > If I change the checkbox to an ImageButton, it all works fine - the > Javascript window as well as going to the function after the Yes button is > pressed. > <asp:ImageButton ID="XferToDefault" OnClick="XferToDefault_Click" > ImageUrl="../../buttons/xfer.gif" runat="server"/> > > Why doesn't the checkbox (or radiobutton) work? > > Thanks, > > Tom > >
Tom,
If an input html control, such as a regular button, or a checkbox, has both
client- and server-side onclick event assigned, asp.net arranges it in the
way
onclick="<javascript for client-side>; <javascript to invoke server-side
handler>;"
In your case you had
onclick="return confirm(...); <javascript to invoke server-side handler>;"
Obviously, the javascript to invoke server-side handler never had its chance
to run.
For ImageButton, which renders as <input type=image>, asp.net apparently
arranges event handlers differently.
Eliyahu
"tshad" <tf*@dslextreme.com> wrote in message
news:uv**************@TK2MSFTNGP14.phx.gbl... "Eliyahu Goldin" <re*************@monarchmed.com> wrote in message news:eG**************@TK2MSFTNGP15.phx.gbl... One more bracket:
XferToDefault.Attributes.Add("onclick", "if(!confirm('Are you sure you want copy these entries?'))return;")
That works fine now,
How come?
Why didn't the other one work if it worked with the asp:imageButton and asp:linkbutton?
Thanks,
Tom
-- Eliyahu
"tshad" <tf*@dslextreme.com> wrote in message news:O5**************@tk2msftngp13.phx.gbl... "Eliyahu Goldin" <re*************@monarchmed.com> wrote in message news:ui**************@tk2msftngp13.phx.gbl... > Tom, > > Try > > XferToDefault.Attributes.Add("onclick", "if(!confirm('Are you sure you want > copy these entries?')return;")
I tried that, but there must be a problem with the Javascript. I
don't get the confirm box at all now, as well as not going to the function.
Tom
> > If it works, I can explain the reason. > > Eliyahu > > "tshad" <tf*@dslextreme.com> wrote in message > news:%2****************@TK2MSFTNGP09.phx.gbl... > > I have the following code that attaches a Javascript confirm box
to my > > checkbox. When I select the checkbox, the window comes up fine,
but it > > never executes the XfertoDefault_Click function when I press the
Yes > button. > > If I take off the Javascript event, the checkbox works fine. > > > > XferToDefault.Attributes.Add("onclick", "return confirm('Are you
sure you > > want copy these entries?');") > > > > <asp:CheckBox ID="XferToDefault" AutoPostBack="true" > > OnCheckedChanged="XferToDefault_Click" runat="server"/> > > > > If I change the checkbox to an ImageButton, it all works fine -
the > > Javascript window as well as going to the function after the Yes
button is > > pressed. > > <asp:ImageButton ID="XferToDefault" OnClick="XferToDefault_Click" > > ImageUrl="../../buttons/xfer.gif" runat="server"/> > > > > Why doesn't the checkbox (or radiobutton) work? > > > > Thanks, > > > > Tom > > > > > >
Eliyahu Goldin wrote: Tom,
If an input html control, such as a regular button, or a checkbox, has both client- and server-side onclick event assigned, asp.net arranges it in the way
onclick="<javascript for client-side>; <javascript to invoke server-side handler>;"
... apart from the ";" inbetween, you have to add that yourself to your (client-side) code!
In your case you had
onclick="return confirm(...); <javascript to invoke server-side handler>;"
Obviously, the javascript to invoke server-side handler never had its chance to run.
For ImageButton, which renders as <input type=image>, asp.net apparently arranges event handlers differently.
Eliyahu
"tshad" <tf*@dslextreme.com> wrote in message news:uv**************@TK2MSFTNGP14.phx.gbl... "Eliyahu Goldin" <re*************@monarchmed.com> wrote in message news:eG**************@TK2MSFTNGP15.phx.gbl... One more bracket:
XferToDefault.Attributes.Add("onclick", "if(!confirm('Are you sure you want copy these entries?'))return;")
That works fine now,
How come?
Why didn't the other one work if it worked with the asp:imageButton and asp:linkbutton?
Thanks,
Tom
-- Eliyahu
"tshad" <tf*@dslextreme.com> wrote in message news:O5**************@tk2msftngp13.phx.gbl... "Eliyahu Goldin" <re*************@monarchmed.com> wrote in message news:ui**************@tk2msftngp13.phx.gbl... > Tom, > > Try > > XferToDefault.Attributes.Add("onclick", "if(!confirm('Are you > sure you want copy these entries?')return;")
I tried that, but there must be a problem with the Javascript. I don't get the confirm box at all now, as well as not going to the function.
Tom
> > If it works, I can explain the reason. > > Eliyahu > > "tshad" <tf*@dslextreme.com> wrote in message > news:%2****************@TK2MSFTNGP09.phx.gbl... >> I have the following code that attaches a Javascript confirm box >> to my checkbox. When I select the checkbox, the window comes up >> fine, but it never executes the XfertoDefault_Click function >> when I press the Yes button. If I take off the Javascript event, >> the checkbox works fine. >> >> XferToDefault.Attributes.Add("onclick", "return confirm('Are you >> sure you want copy these entries?');") >> >> <asp:CheckBox ID="XferToDefault" AutoPostBack="true" >> OnCheckedChanged="XferToDefault_Click" runat="server"/> >> >> If I change the checkbox to an ImageButton, it all works fine - >> the Javascript window as well as going to the function after the >> Yes button is pressed. >> <asp:ImageButton ID="XferToDefault" OnClick="XferToDefault_Click" >> ImageUrl="../../buttons/xfer.gif" runat="server"/> >> >> Why doesn't the checkbox (or radiobutton) work? >> >> Thanks, >> >> Tom
> > If an input html control, such as a regular button, or a checkbox, has both client- and server-side onclick event assigned, asp.net arranges it in the way
onclick="<javascript for client-side>; <javascript to invoke server-side handler>;"
.. apart from the ";" inbetween, you have to add that yourself to your
(client-side) code!
No, asp.net does it for you if you have a server-side onclick event set. You
will find a __doPostBack... call over there.
For example, it will be produced for the following html:
<input type=button runat=server onclick="clientValidate()"
onserverclick="ServerValidate" ... >
Eliyahu
"Hans Kesting" <ne***********@spamgourmet.com> wrote in message
news:O%******************@TK2MSFTNGP12.phx.gbl... Eliyahu Goldin wrote: Tom,
If an input html control, such as a regular button, or a checkbox, has both client- and server-side onclick event assigned, asp.net arranges it in the way
onclick="<javascript for client-side>; <javascript to invoke server-side handler>;"
.. apart from the ";" inbetween, you have to add that yourself to your (client-side) code!
But I didn't have to for the linkbutton or imagebutton.
Tom In your case you had
onclick="return confirm(...); <javascript to invoke server-side handler>;"
Obviously, the javascript to invoke server-side handler never had its chance to run.
For ImageButton, which renders as <input type=image>, asp.net apparently arranges event handlers differently.
Eliyahu
"tshad" <tf*@dslextreme.com> wrote in message news:uv**************@TK2MSFTNGP14.phx.gbl... "Eliyahu Goldin" <re*************@monarchmed.com> wrote in message news:eG**************@TK2MSFTNGP15.phx.gbl... One more bracket:
XferToDefault.Attributes.Add("onclick", "if(!confirm('Are you sure you want copy these entries?'))return;")
That works fine now,
How come?
Why didn't the other one work if it worked with the asp:imageButton and asp:linkbutton?
Thanks,
Tom
-- Eliyahu
"tshad" <tf*@dslextreme.com> wrote in message news:O5**************@tk2msftngp13.phx.gbl... > "Eliyahu Goldin" <re*************@monarchmed.com> wrote in message > news:ui**************@tk2msftngp13.phx.gbl... >> Tom, >> >> Try >> >> XferToDefault.Attributes.Add("onclick", "if(!confirm('Are you >> sure you want copy these entries?')return;") > > I tried that, but there must be a problem with the Javascript. I > don't get the confirm box at all now, as well as not going to the > function. > > Tom > >> >> If it works, I can explain the reason. >> >> Eliyahu >> >> "tshad" <tf*@dslextreme.com> wrote in message >> news:%2****************@TK2MSFTNGP09.phx.gbl... >>> I have the following code that attaches a Javascript confirm box >>> to my checkbox. When I select the checkbox, the window comes up >>> fine, but it never executes the XfertoDefault_Click function >>> when I press the Yes button. If I take off the Javascript event, >>> the checkbox works fine. >>> >>> XferToDefault.Attributes.Add("onclick", "return confirm('Are you >>> sure you want copy these entries?');") >>> >>> <asp:CheckBox ID="XferToDefault" AutoPostBack="true" >>> OnCheckedChanged="XferToDefault_Click" runat="server"/> >>> >>> If I change the checkbox to an ImageButton, it all works fine - >>> the Javascript window as well as going to the function after the >>> Yes button is pressed. >>> <asp:ImageButton ID="XferToDefault" OnClick="XferToDefault_Click" >>> ImageUrl="../../buttons/xfer.gif" runat="server"/> >>> >>> Why doesn't the checkbox (or radiobutton) work? >>> >>> Thanks, >>> >>> Tom
"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl... > If an input html control, such as a regular button, or a checkbox, > has both client- and server-side onclick event assigned, asp.net > arranges it in the way > > onclick="<javascript for client-side>; <javascript to invoke > server-side handler>;" > .. apart from the ";" inbetween, you have to add that yourself to your (client-side) code!
No, asp.net does it for you if you have a server-side onclick event set. You will find a __doPostBack... call over there.
For example, it will be produced for the following html:
<input type=button runat=server onclick="clientValidate()" onserverclick="ServerValidate" ... >
So how is:
if(!confirm('Are you sure you want copy these entries?'))return;
different from:
return confirm('Are you sure you want copy these entries?');
That the 1st one works and the 2nd one doesn't?
Tom Eliyahu
tshad wrote: "Eliyahu Goldin" <re*************@monarchmed.com> wrote in message news:%2****************@TK2MSFTNGP09.phx.gbl... If an input html control, such as a regular button, or a checkbox, has both client- and server-side onclick event assigned, asp.net arranges it in the way
onclick="<javascript for client-side>; <javascript to invoke server-side handler>;"
.. apart from the ";" inbetween, you have to add that yourself to your (client-side) code!
No, asp.net does it for you if you have a server-side onclick event set. You will find a __doPostBack... call over there.
For example, it will be produced for the following html:
<input type=button runat=server onclick="clientValidate()" onserverclick="ServerValidate" ... >
So how is:
if(!confirm('Are you sure you want copy these entries?'))return;
different from:
return confirm('Are you sure you want copy these entries?');
That the 1st one works and the 2nd one doesn't?
Tom Eliyahu
return confirm() always returns (true or false)
if (!confirm()) return; only returns (without value) if *not* confirmed
and continues (with the postback presumably) if it *is* confirmed.
Hans Kesting
check boxes do not postback automatically. .net add client script (a call to
__doPostback), after any script you add. if your client code does a return,
the postback script will not be called.
-- bruce (sqlwork.com)
"tshad" <ts**********@ftsolutions.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl... "Eliyahu Goldin" <re*************@monarchmed.com> wrote in message news:%2****************@TK2MSFTNGP09.phx.gbl... > If an input html control, such as a regular button, or a checkbox, > has both client- and server-side onclick event assigned, asp.net > arranges it in the way > > onclick="<javascript for client-side>; <javascript to invoke > server-side handler>;" >
.. apart from the ";" inbetween, you have to add that yourself to your (client-side) code!
No, asp.net does it for you if you have a server-side onclick event set. You will find a __doPostBack... call over there.
For example, it will be produced for the following html:
<input type=button runat=server onclick="clientValidate()" onserverclick="ServerValidate" ... >
So how is:
if(!confirm('Are you sure you want copy these entries?'))return;
different from:
return confirm('Are you sure you want copy these entries?');
That the 1st one works and the 2nd one doesn't?
Tom Eliyahu
"Bruce Barker" <br******************@safeco.com> wrote in message
news:Or**************@tk2msftngp13.phx.gbl... check boxes do not postback automatically. .net add client script (a call to __doPostback), after any script you add. if your client code does a return, the postback script will not be called.
But in my case, I am doing an autoPostback=true and it does postback (if you
didn't have the old type of javascript connected to it).
Tom -- bruce (sqlwork.com)
"tshad" <ts**********@ftsolutions.com> wrote in message news:%2****************@TK2MSFTNGP12.phx.gbl... "Eliyahu Goldin" <re*************@monarchmed.com> wrote in message news:%2****************@TK2MSFTNGP09.phx.gbl... > If an input html control, such as a regular button, or a checkbox, > has both client- and server-side onclick event assigned, asp.net > arranges it in the way > > onclick="<javascript for client-side>; <javascript to invoke > server-side handler>;" >
.. apart from the ";" inbetween, you have to add that yourself to your (client-side) code!
No, asp.net does it for you if you have a server-side onclick event set. You will find a __doPostBack... call over there.
For example, it will be produced for the following html:
<input type=button runat=server onclick="clientValidate()" onserverclick="ServerValidate" ... >
So how is:
if(!confirm('Are you sure you want copy these entries?'))return;
different from:
return confirm('Are you sure you want copy these entries?');
That the 1st one works and the 2nd one doesn't?
Tom Eliyahu
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: VictorG |
last post by:
Hello,
I am new to JS and am trying to add some HTML into a JS function. So
that when called the script as well as the HTML will be invoked. Is
there some type of embed mechanism, sort of the...
|
by: Matt Kruse |
last post by:
http://www.JavascriptToolbox.com/bestpractices/
I started writing this up as a guide for some people who were looking for
general tips on how to do things the 'right way' with Javascript. Their...
|
by: Muhammad Abdullah |
last post by:
Hi
am having some problems with the javascript confirm.
i have it working fine on one page and it doesnt even pop up at the
other.
The code on the working page is,
private void...
|
by: den2005 |
last post by:
Hi everybody,
I am confused and still looking why this codes is not working. Can anyone notice or know why this code is not working? Thanks in advance.
Code working:
<form id="form1"...
|
by: Nathan Sokalski |
last post by:
I add several JavaScript events (onchange, onkeypress, etc.) to Controls
using the Add method of the Attributes collection. However, if the
JavaScript code contains certain characters, such as & or...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
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...
|
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...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
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...
|
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)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
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....
|
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
| |