Error with client script + EditCommands

Discussion in 'ASP .Net' started by =?Utf-8?B?Q2hhZA==?=, Jul 7, 2005.

  1. Hi,

    I have the following server code that attaches a client side script to the
    Update command of the data grid.
    Private Sub clientExc_ItemCreated(ByVal sender As Object, _
    ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs)
    Handles clientExc.ItemCreated

    If e.Item.ItemType = ListItemType.EditItem Then
    CType(e.Item.Cells(4).Controls(0),
    LinkButton).Attributes.Add("onclick", "buttonClick(this);")
    End If
    End Sub


    The javascript is in an external js file.

    What happens is when the page is loading in Edit mode after clicking the
    edit button, but before clicking the update button, I see the following
    script error:
    'undefined' is null or not an object.

    I have no idea what it is complaining about. If you have any ideas or
    suggestions please feel free to post them.

    Thank You!
     
    =?Utf-8?B?Q2hhZA==?=, Jul 7, 2005
    #1
    1. Advertising

  2. This usually means that the function is not correctly specified, misspelled
    or missing.

    Make sure that you are correctly referencing the JavaScript file on your
    page. You can debug JavaScript by looking at the running documents when you
    are in debug mode.

    Also, view source when your page loads in the browser. Make sure that the
    script was attached and the reference is included in the page.
    --
    Staff Consultant II
    Enterprise Web Services
    Cardinal Solutions Group

    Future Business Model
    Loan Origination Services
    National City Mortgage


    "Chad" wrote:

    > Hi,
    >
    > I have the following server code that attaches a client side script to the
    > Update command of the data grid.
    > Private Sub clientExc_ItemCreated(ByVal sender As Object, _
    > ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs)
    > Handles clientExc.ItemCreated
    >
    > If e.Item.ItemType = ListItemType.EditItem Then
    > CType(e.Item.Cells(4).Controls(0),
    > LinkButton).Attributes.Add("onclick", "buttonClick(this);")
    > End If
    > End Sub
    >
    >
    > The javascript is in an external js file.
    >
    > What happens is when the page is loading in Edit mode after clicking the
    > edit button, but before clicking the update button, I see the following
    > script error:
    > 'undefined' is null or not an object.
    >
    > I have no idea what it is complaining about. If you have any ideas or
    > suggestions please feel free to post them.
    >
    > Thank You!
     
    =?Utf-8?B?TWljaGFlbCBCYWx0aWM=?=, Jul 7, 2005
    #2
    1. Advertising

  3. It appears to be executing the javascript code because an alert box i
    showing, I can't seem to figure out how to debug the script.
     
    =?Utf-8?B?Q2hhZA==?=, Jul 7, 2005
    #3
  4. OK I got it to debug finally, the error is in a MS Script
    function ValidatorOnLoad
    Very strang since I commented out these controls, now I removed them and no
    error.
     
    =?Utf-8?B?Q2hhZA==?=, Jul 7, 2005
    #4
  5. You commented out the controls on your aspx page or the code behind? If you
    commented them out of the aspx page, then they might still be in the code
    behind page. They would get added to the form on load, then the client side
    script wouldn't see the validator object. Boom! Error! When you comment
    out a control on the aspx page, make sure they are removed from the code
    behind.

    The IDE will usually re-declare the object if you comment it out in the code
    behind and not the aspx page.
    --
    Staff Consultant II
    Enterprise Web Services
    Cardinal Solutions Group

    Future Business Model
    Loan Origination Services
    National City Mortgage


    "Chad" wrote:

    > OK I got it to debug finally, the error is in a MS Script
    > function ValidatorOnLoad
    > Very strang since I commented out these controls, now I removed them and no
    > error.
     
    =?Utf-8?B?TWljaGFlbCBCYWx0aWM=?=, Jul 7, 2005
    #5
  6. I commented out the controls in the aspx page and verfied that there was no
    more declarations for them in the codebehind. The page must have been cached
    or something, not sure.
    Thank you for your help!
     
    =?Utf-8?B?Q2hhZA==?=, Jul 7, 2005
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Magnus Blomberg
    Replies:
    3
    Views:
    720
    Magnus Blomberg
    Apr 14, 2005
  2. Boss302
    Replies:
    0
    Views:
    1,056
    Boss302
    Nov 21, 2006
  3. =?Utf-8?B?TG93bGFuZGVy?=
    Replies:
    0
    Views:
    378
    =?Utf-8?B?TG93bGFuZGVy?=
    Mar 27, 2007
  4. Rajat
    Replies:
    3
    Views:
    705
    Jorgen Grahn
    Jan 8, 2010
  5. Andrea Williams

    Adding client-script to handle client events

    Andrea Williams, Apr 12, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    132
    Andrea Williams
    Apr 12, 2004
Loading...

Share This Page