开发者

Call JavaScript AND C# function from a button

开发者 https://www.devze.com 2022-12-15 14:41 出处:网络
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\'

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"
开发者_StackOverflow社区                    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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消