【发布时间】:2015-04-17 10:43:54
【问题描述】:
我有下一个用户网络控制:
<script type="text/javascript">
function Myfunction() {
alert('Hello');
}
</script>
<asp:Panel Id="problemSolving_panel" runat="server">
<asp:Button ID="Button1" runat="server" Text="Hello world" OnClientClick="javascript:Myfunction();return false;"/>
<fieldset class="fieldsetsElement">
<legend class="legendsElement">
<input Id="callToAbonent" runat="server" type="checkbox" onchange ="ChangeEnable(this.checked, 'callToAbonentDiv');"/>
<label for="callToAbonent">Call to abonent:</label>
</legend>
<div Id="callToAbonentDiv">
<asp:CheckBox Id="isCallToAbonentFailed" runat="server" Text="Call to abonent failed" Enabled="false"/>
<br />
<asp:Table runat="server" Enabled="false">
<asp:TableRow>
<asp:TableCell>
<asp:TextBox Id="datesOfCallTrying" runat="server" />
</asp:TableCell>
<asp:TableCell>
<asp:Button ID="Button2" runat="server" Text="Hello world" OnClientClick="javascript:Myfunction();return true;"/>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
<br />
<asp:Button Id="addInfoAboutCall_button" runat="server" Text="Add info about call" Enabled="false" OnClick="OnAddInfoAboutCall"/>
</div>
</fieldset>
</asp:Panel>
当我点击 Button1 时,OnClientClick 处理此事件,向我显示“你好”,没有任何回发到服务器,但是当我点击 Button2(Button1 的复制粘贴)时,OnClientClick 不处理点击事件并且服务器服务器得到回发。我不明白为什么会这样,因为我不需要回发。谁能告诉我我的代码有什么问题?
【问题讨论】:
-
在javascript端使用return false。这将取消回发
标签: javascript c# asp.net