admin管理员组文章数量:1431406
I have a few controls designed to verify certain data before a user may do a soft delete on server data.
The error:
Compiler Error Message: CS1061: 'ASP.editdivision_aspx' does not contain a definition for 'show_confirm' and no extension method 'show_confirm' accepting a first argument of type 'ASP.editdivision_aspx' could be found (are you missing a using directive or an assembly reference?)
Line 28: <td><asp:TextBox runat="server" ID="txtDivisionName" Width="250" /></td>
Line 29: </tr>
Line 30: <tr><td><asp:CheckBox ID="chkDelete" runat="server" Text="Delete" OnCheckedChanged="show_confirm" /></td></tr>
Line 31: <tr><td><asp:Button ID="btnSave" runat="server" Text="Save" OnClick="SaveClick" /></td></tr>
Line 32: </table>
The script:
<script type="text/jscript" >
function show_confirm() {
PageMethods.VerifyDelete(CallSuccess, CallFailed);
}
function CallSuccess(res, destCtrl) {}
function CallFailed(res, destCtrl) {
var r = confirm("There are active Campaigns in this Division!\nAre you sure you want to proceed?");
if (r == true) {
PageMethods.Save();
//alert("Division and related Campaigns deleted.");
}
}
</script>
I have been unable to determine why I am getting this runtime error. I am new to asp and javascript so I am sure it is something simple I missed, but I have been searching for 2 days on what the problem is.
I have a few controls designed to verify certain data before a user may do a soft delete on server data.
The error:
Compiler Error Message: CS1061: 'ASP.editdivision_aspx' does not contain a definition for 'show_confirm' and no extension method 'show_confirm' accepting a first argument of type 'ASP.editdivision_aspx' could be found (are you missing a using directive or an assembly reference?)
Line 28: <td><asp:TextBox runat="server" ID="txtDivisionName" Width="250" /></td>
Line 29: </tr>
Line 30: <tr><td><asp:CheckBox ID="chkDelete" runat="server" Text="Delete" OnCheckedChanged="show_confirm" /></td></tr>
Line 31: <tr><td><asp:Button ID="btnSave" runat="server" Text="Save" OnClick="SaveClick" /></td></tr>
Line 32: </table>
The script:
<script type="text/jscript" >
function show_confirm() {
PageMethods.VerifyDelete(CallSuccess, CallFailed);
}
function CallSuccess(res, destCtrl) {}
function CallFailed(res, destCtrl) {
var r = confirm("There are active Campaigns in this Division!\nAre you sure you want to proceed?");
if (r == true) {
PageMethods.Save();
//alert("Division and related Campaigns deleted.");
}
}
</script>
I have been unable to determine why I am getting this runtime error. I am new to asp and javascript so I am sure it is something simple I missed, but I have been searching for 2 days on what the problem is.
Share Improve this question edited Nov 16, 2011 at 16:35 BNL 7,1234 gold badges29 silver badges32 bronze badges asked Nov 16, 2011 at 16:26 scott.smartscott.smart 5385 silver badges16 bronze badges2 Answers
Reset to default 3The attribute OnCheckedChanged
requires a server-side event handler, not a javascript function.
Try the onchange
attribute which is the standard html attribute for the client-side event:
<asp:CheckBox ID="chkDelete" runat="server" Text="Delete" onchange="show_confirm()" />
Edit:
It seems asp is generating a element and applies the 'onchange' on the span and not the .
Found this post that deals with this problem: Add client-side onchange handler to ASP.NET CheckBox control
This is what worked for me, onchange and OnClientClick did not work, onclick did:
<asp:CheckBox ID="EnabledCheckBox" runat="server" OnClick="showDiv(this.checked);"/>
<div id="ShowDiv">Show me now</div>
Javascript:
function showDiv(show) {
if (show) {
$('#ShowDiv').show("slow");
} else {
$('#ShowDiv').hide("slow");
}
}
本文标签: cCheckBox event can not find javascript functionStack Overflow
版权声明:本文标题:c# - CheckBox event can not find javascript function - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745496320a2660822.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论