Home All Groups Group Topic Archive Search About

cancel toolbar buttonclick from client-side javascript

Author
13 Feb 2006 6:21 PM
John C.
Hi, I'm using the webcontrols toolbar. Is it possible to cancel the
postback which drives the server-side events by using some client-side
javascript, something along the lines of
    window.event.returnValue = window.confirm('test1');
within the onclick= or onbuttonclick= of the toolbar?

When I try to add my own script to the onbuttonclick :
<%@ Register TagPrefix="iewc" Namespace="Microsoft.Web.UI.WebControls"
Assembly="Microsoft.Web.UI.WebControls, Version=1.0.2.116,
Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<iewc:toolbar id="tbTest" runat="server" onbuttonclick="test();">
    <iewc:toolbarbutton text="165" imageurl="../../../images/btn_new.gif"
id="btnTest"></iewc:toolbarbutton>
</iewc:toolbar>

it causes an error:
Compiler Error Message: CS1026: ) expected

Yet when I remove the onbuttonclick handler, the HTML rendered to the
browser contains an onbuttonclick handler with all the postback logic:
onbuttonclick="JScript:if (event.srcNode != null) if
((event.srcNode.getType() != 'checkbutton') ||
(event.srcNode.getAttribute('_autopostback') != null)) if
(getAttribute('_submitting') != 'true'){setAttribute('_submitting',
'true');try{__doPostBack('Panel1$tbPanelToolbar',event.flatIndex);}catch(e){setAttribute('_submitting',
'false');}}"

So I just want to interject in front of the canned script. Is that
possible?

John

Author
14 Feb 2006 8:11 PM
Alvin Bruney - ASP.NET MVP
you are on the right track, but you will need to return false from the
function to suppress it.
onbuttonclick="test();" return false; roughly
--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
-------------------------------------------------------



Show quoteHide quote
"John C." <vbhackatt***@hotmail.com> wrote in message
news:1139854909.608976.136390@g44g2000cwa.googlegroups.com...
> Hi, I'm using the webcontrols toolbar. Is it possible to cancel the
> postback which drives the server-side events by using some client-side
> javascript, something along the lines of
> window.event.returnValue = window.confirm('test1');
> within the onclick= or onbuttonclick= of the toolbar?
>
> When I try to add my own script to the onbuttonclick :
> <%@ Register TagPrefix="iewc" Namespace="Microsoft.Web.UI.WebControls"
> Assembly="Microsoft.Web.UI.WebControls, Version=1.0.2.116,
> Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
> <iewc:toolbar id="tbTest" runat="server" onbuttonclick="test();">
> <iewc:toolbarbutton text="165" imageurl="../../../images/btn_new.gif"
> id="btnTest"></iewc:toolbarbutton>
> </iewc:toolbar>
>
> it causes an error:
> Compiler Error Message: CS1026: ) expected
>
> Yet when I remove the onbuttonclick handler, the HTML rendered to the
> browser contains an onbuttonclick handler with all the postback logic:
> onbuttonclick="JScript:if (event.srcNode != null) if
> ((event.srcNode.getType() != 'checkbutton') ||
> (event.srcNode.getAttribute('_autopostback') != null)) if
> (getAttribute('_submitting') != 'true'){setAttribute('_submitting',
>
'true');try{__doPostBack('Panel1$tbPanelToolbar',event.flatIndex);}catch(e){
setAttribute('_submitting',
Show quoteHide quote
> 'false');}}"
>
> So I just want to interject in front of the canned script. Is that
> possible?
>
> John
>
Author
23 Feb 2006 4:20 PM
John C.
Hi Alvin, I am returning false from my function but that doesn't really
matter since the javascript won't compile, as per the message "Compiler
Error Message: CS1026: ) expected". It seems that it is not possible to
specify the onbuttonclick handler in the tag because the IEWC doesn't
support this. That is the crux of my question.