简体   繁体   English

Microsoft JScript运行时错误“ btn_click”未定义

[英]microsoft jscript runtime error 'btn_click' is undefined

Using Jquery I was able to pop up a dialog window using a link button and it's nothing but the div tag being popped up. 使用Jquery,我能够使用链接按钮弹出一个对话框窗口,不过只是弹出了div标签。

The pop up window consists of a TextBox and button. 弹出窗口由一个TextBox和一个按钮组成。

This is the button coded in *.aspx file: 这是* .aspx文件中编码的按钮:

<asp:Button ID="btnSubmitComment" runat="server" onclick="btnSubmitComment_Click" style="display:none;" />

In Jquery : 在Jquery中:

  $(function () {
    var dlg = $("#divEditComment").dialog({
        autoOpen: false,
        show: "blind",
        hide: "blind",
        //height: 200,
        minWidth: 220,
        //position: ['right', 210],
        buttons: {
            "Update Note": function () {

                var Updates = btnSubmitComment.replace(/_/g, '$');
                __doPostBack(Updates, '');
            }
        }
    });
    dlg.parent().appendTo(jQuery("form:first"));
});

divEditComment is the div tag which acts as dialog box. divEditComment是用作对话框的div标签。 In this dialog box, the button which is not working exists. 在此对话框中,存在不起作用的按钮。

In C# code-behind, I have declared: 在C#后台代码中,我声明了:

protected void btnSubmitComment_Click(object sender, EventArgs e)
{
}

Still I am getting the error: 仍然我得到错误:

microsoft jscript runtime error 'btnSubmitComment' is undefined Microsoft JScript运行时错误“ btnSubmitComment”未定义

I am not understanding where I'm wrong. 我不明白我在哪里错。

If you need the id of an asp.net control you can use <%= btnSubmitComment.ClientId %> which will be replaced by asp.net to btnSubmitComment's id, for example: 如果需要asp.net控件的ID,则可以使用<%= btnSubmitComment.ClientId%>,它将由asp.net替换为btnSubmitComment的ID,例如:

var btnSubmitComment  = $('#<%= btnSubmitComment.ClientId %>')

will get btnSubmitComment as a jQuery object. 将btnSubmitComment作为jQuery对象。

or using only jQuery: 或仅使用jQuery:

var btnSubmitComment  = $('[id$=btnSubmitComment]');
var id = btnSubmitComment.attr('id');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Microsoft JScript运行时错误:“ clientUploadComplete”未定义 - Microsoft JScript runtime error: 'clientUploadComplete' is undefined 使btn_Click事件为静态 - making btn_Click event static C# 如何在 object 中创建 Btn_click 事件访问由另一个 Btn_Click - C# how to object created in Btn_click event access by another Btn_Click Microsoft JScript运行时错误:预期对象 - Microsoft JScript runtime error: Object expected Microsoft JScript运行时错误:“null”为null或不是对象 - Microsoft JScript runtime error: 'null' is null or not an object BHO插件(Microsoft JScript运行时错误) - BHO Plugin (Microsoft JScript runtime error) jQuery“Microsoft JScript运行时错误:对象预期” - jQuery “Microsoft JScript runtime error: Object expected” Fancybox Microsoft JScript 运行时错误:权限被拒绝 - Fancybox Microsoft JScript runtime error: Permission denied Microsoft JScript中的运行时错误:未定义“数组” - Runtime Error in Microsoft JScript: 'Array' is not defined 每次单击“ Microsoft JScript运行时错误:Sys.WebForms.PageRequestManagerServerErrorException:”错误。 <asp:ImageButton /> - Getting a “Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException:” error everytime I click on a <asp:ImageButton />
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM