Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Apr 2008
    Thanked 0 Times in 0 Posts

    Exclamation Javascript Error: Object Required: Asp.net

    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
    Last edited by jmohan; 12-16-2011 at 07:24 AM.

  2. #2
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Thanked 210 Times in 209 Posts
    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

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts