本文介绍了如何在href onclick事件中调用c#函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞!<a href="#" runat="server" önclick="<% getPKWhales();%>" style="height:7px;width:40px;border:outset">PK</a> 函数The functionpublic void getPKWhalse() { SessionHandler.wMenu = SessionHandler.MenuVariable.WHALES; Session["who"] = "pkwhales"; SessionHandler.RedirectPage("~/form/whales.aspx"); } 可以在href标签的onclick事件中调用上面的getPKWhale()函数, 在我的项目中没有工作,我想做什么,调用该函数Ccan i call the above getPKWhale() function in onclick event of a href tag,which is not worked in my project, what else i wants to do , to call that function推荐答案<script runat="server"> protected void btnSubmit_Click(object sender, EventArgs e) { getPKWhalse(); }</script><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Click Server Button Evnet By JavaScript</title> <script language="javascript" type="text/javascript"> function fireServerButtonEvent(){ document.getElementById("btnSubmit").click(); } </script></head><body> <form id="form1" runat="server"> <div> <asp:label id="lblMessage" runat="server" text="" xmlns:asp="#unknown"></asp:label> <asp:button id="btnSubmit" runat="server" text="Submit" xmlns:asp="#unknown"> onclick="btnSubmit_Click" style="display:none" /> <a href="http://www.asp.net" onclick="fireServerButtonEvent()">Go!</a> </asp:button></div> </form></body></html> 这篇关于如何在href onclick事件中调用c#函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-07 04:47