Alwyn Miranda
Alwyn Miranda

Reputation: 370

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.

The pop up window consists of a TextBox and button.

This is the button coded in *.aspx file:

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

In 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. In this dialog box, the button which is not working exists.

In C# code-behind, I have declared:

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

Still I am getting the error:

microsoft jscript runtime error 'btnSubmitComment' is undefined

I am not understanding where I'm wrong.

Upvotes: 0

Views: 1084

Answers (1)

nima
nima

Reputation: 6733

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:

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

will get btnSubmitComment as a jQuery object.

or using only jQuery:

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

Upvotes: 1

Related Questions