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 2043
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 discussion thread is closed Replies have been disabled for this discussion. Similar topics
10 posts
views
Thread by VictorG |
last post: by
|
136 posts
views
Thread by Matt Kruse |
last post: by
|
1 post
views
Thread by Muhammad Abdullah |
last post: by
| |
11 posts
views
Thread by Nathan Sokalski |
last post: by
| | | | | | | | | | |