【发布时间】:2013-06-22 06:18:53
【问题描述】:
我有一个使用更新面板的 aspx 页面
我放置在页面中间的某些功能比按钮客户端单击时无法调用它们。
这样的代码不起作用
案例 1:
<%--some html--%>
<asp:Button ID="btnBotton" runat="server" OnClientClick="return callfunction();" Text="Submit"/>
<asp:UpdatePanel runat="server">
<ContentTemplate>
<%--some content here--%>
</ContentTemplate>
<Triggers>
<%--async trigger --%>
</Triggers>
</asp:UpdatePanel>
<script type="text/javascript">
function callfunction() {//function placed at the middle of page
alert('hello');
}
</script>
<%--some html again--%>
</asp:Content>
如果我将函数放在页面末尾而不是调用函数
案例 2:
<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="MainContent">
<%--some html--%>
<asp:Button ID="Button1" runat="server" OnClientClick="return callfunction();" Text="Submit"/>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<%--some content here--%>
</ContentTemplate>
<Triggers>
<%--async trigger --%>
</Triggers>
</asp:UpdatePanel>
<%--some html again--%>
<script type="text/javascript">
function callfunction() {//function placed at the middle of page
alert('hello');
}
</script>
</asp:Content>
所以我想知道案例 1 的问题是什么?为什么我无法调用函数
【问题讨论】:
-
我不想从后面的代码中调用函数。很简单,在 OnClientClick 我想调用 jquery 函数
标签: javascript jquery asp.net updatepanel