View Full Version : Javascript Error: Object Required: Asp.net

12-16-2011, 07:21 AM
Hi everyone,

I am unable to find out the Id in Javascript from the server control.

I have used the following code,

<asp:GridView ID="GridView1" runat="server">
<asp:CheckBox ID="chkboxHeader" runat="server" AutoPostBack="false" onclick="javascript:selectallrow(this.Id);" />
<asp:CheckBox ID="chkboxBody" runat="server" />

function selectallrow(Id)
var getobj=document.getElementById(Id).value;

I have replaced also the following script, but nothing works,
var getobj=document.getElementById("<%=Id.ClientID %>").value;

But 'Object required error occurred'
Please provide me a solution

thanks in advance,

Mohan J

12-16-2011, 04:37 PM
first a few things to try-
have you run debug and seen what values are?
set break point on the script call and in immediate window check value of the id being passed by the onclick function. Also I do not see any field value="something" so how can you target that id's value if it does not exist? But I think the more underlying problem is probably that <asp: objects "onclick" events target the code behind function... try OnClientClick="" ... i think there are probably a few things you will need to debug.

Edit: as a side note if you set the break points and are not using IE for default browser, I do not think visual studio will break on it- I have had problems w/ this in the past trying to us chrome as default browser. *the only reason IE is my default browser ;)