Tutorial :Call JavaScript AND C# function from a button



Question:

I am trying to run a routine that (when a button is clicked) changes an asp:label's text to "Please Wait..." using Javascript, and then goes away and runs a c# function that changes the asp:label's text to "Finished" when it is complete.

I can get the Javascript to work:

<asp:Button ID="Button1" runat="server" Text="Upload"                      onclientclick="document.getElementById('errorMessage').innerText='Please Wait...';" />  

And I can run the c# bit fine too:

<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />  

But I can't figure out how to make them run together. (i.e. Javascript first, and then c#.

Cheers for any advice,

Ben


Solution:1

OK - that was obvious:

<asp:Button ID="Button1" runat="server" Text="Upload"                      onclientclick="document.getElementById('errorMessage').innerText='Please Wait...';"                       onclick="Button1_Click"  />  

Thanks anyway!

Ben


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »