I keep getting the ‘Object Expected‘ error within my page script when I click the button.
I’ve debugged using fire-bug and the id passed to the JavaScript method is the correct id and document.getElementById(a) finds the button. The error keeps occurring in the _doPostBack. Can this be caused because the button is inside a modal popup in a gridview cell, and the gridview is inside a update panel.
For complete code please see this previous question event not firing I posted and resolved.
The reason I’m still using the JavaScript is the Post-Back event in the GridView.RowCommand did not occur without this.
Is there an alternative to this?
The code:
function addAcc(a) {
var btn = document.getElementById(a); //get the button, not necessary but safer
alert(a); //To see the button id
_doPostBack(btn.id, ''); //do the postback so RowCommand Fires in code behind
};
<asp:Button ID="btnAddAcc" runat="server" Text="Add Account"
OnClientClick="javascript:addAcc(this.id)" />
Thank you for any solutions and ideas.
Regards
the dopostback method is with two underscores not one, like
so your call is like:
instead of