Can I use dojotype and onServerClick at the same time?

I tried using onserverclick while having dojotype in my button.

See this code.

<button id="ButtonLogin" runat="server" onServerClick="ButtonLogin_OnClick"   dojotype="dijit.form.Button" jsid="ButtonLogin" style="float: right;
                            padding: 5px 15px 0px 0px;">


So basically I have an empty ButtonLogin_OnClick that will fire after the button is clicked (something warning). and also dojotype runs javascript as well (also warns Something).

<script runat="server">
 void ButtonLogin_OnClick(object sender, EventArgs e)


How I test it. Only the doyotite succeeded.

Can anyone explain this to me or can we use both at the same time?


source to share

5 answers

You need to hook up the onClick of the dojo button to call _doPostback with appropriate parameters. _doPostback is emitted by ASP.NET and it is the mechanism used to trigger postback and execute server side event.



try adding return to your function.

but if you can already use dojo you should go with it to prevent such problems, especially if you are targeting multiple browsers.



While it may not be directly about dojotype, this example might help you. I am using the following to call javascript then to submit.

<asp:Button ID="btnSubmit" runat="server" Text="Send" OnClick="btnSubmit_Click" onclientclick="javascript:alert('A');" />


You can check if the page is valid before javascript execution

<asp:Button ID="btnSubmit" runat="server" Text="Send" OnClick="btnSubmit_Click" onclientclick="javascript:Page_ClientValidate();if(Page_IsValid){ //Do stuff };" />




You can't have both! Basically, dojo and are trying to replace the onClick handler, so you won't see both being executed.

The best solution is to add your reverse logic to the dojo click handler:

<button id="ButtonLogin" runat="server" 
dojotype="dijit.form.Button" jsid="ButtonLogin" 
         style="float: right;padding: 5px 15px 0px 0px;">
  <script type="dojo/method" data-dojo-event="onClick" data-dojo-args="evt">





I think there is a problem in the syntax, the click event is not executed and the function is not a call instead of "onServerClick", you can try "onserverclick". Maybe this will solve your problem ...

Try this code

<button id="ButtonLogin" runat="server" onserverclick="ButtonLogin_OnClick" dojotype="dijit.form.Button" jsid="ButtonLogin" style="float: right;
                            padding: 5px 15px 0px 0px;">Login</button>


otherwise you can call ButtonLogin_OnClick function on the Dojo click event, this will result in the shared event together ...



All Articles