admin管理员组文章数量:1194328
In an asp user control I have a button:
<asp:Button ID="addButton" runat="server" Text="Add" OnClientClick="return function()".
I had written jquery code to hide a control( validationsummary) present in the page inside function().
When I wrote "return function()" it behaved as I expected and the control got hidden. While when I wrote only "function"()" the control got hidden but reappeared. What exactly is the difference between the two?
In an asp.net user control I have a button:
<asp:Button ID="addButton" runat="server" Text="Add" OnClientClick="return function()".
I had written jquery code to hide a control( validationsummary) present in the page inside function().
When I wrote "return function()" it behaved as I expected and the control got hidden. While when I wrote only "function"()" the control got hidden but reappeared. What exactly is the difference between the two?
Share Improve this question asked Nov 17, 2013 at 8:45 user2645830user2645830 3621 gold badge6 silver badges22 bronze badges1 Answer
Reset to default 22First : the client side runs (OnClientClick
)
Then - the server side.
But
The client side code can prevent execution of server side by return true/false.
usually we use it for validation , before submitting to server.
Do this and your server side will ( without hacking) never work :
OnClientClick="return false;"
版权声明:本文标题:c# - Asp .NET Button - OnClientClick="return function()" vs OnClientClick="function()" - Sta 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738469837a2088518.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论