FindControl

Discussion in 'ASP .Net' started by TJS, Mar 7, 2005.

  1. TJS

    TJS Guest

    getting error on this code:

    Dim ctrl As button = FindControl("btnDelete")
    ctrl.Attributes.Add("onclick", "javascript:return confirm('Are you sure
    you want to delete this ? ')")


    error:
    Object reference not set to an instance of an object.

    btnDelete is a button inside another control called "ConfirmForm" but I
    can't seem to find it to add the warning

    What's missing ??
    TJS, Mar 7, 2005
    #1
    1. Advertising

  2. TJS

    David Kyle Guest

    I believe that if you call the "FindControl()" method on the ConfirmForm
    object you will get it to work.

    Eg.

    dim ctrl As button = ConfirmForm.FindControl("btnDelete");
    ctrl.Attributes.Add("onclick", "javascript:return confirm('Are you sure you
    want to delete this ? ')")

    Cheers!

    David Kyle


    "TJS" <> wrote in message
    news:%...
    > getting error on this code:
    >
    > Dim ctrl As button = FindControl("btnDelete")
    > ctrl.Attributes.Add("onclick", "javascript:return confirm('Are you sure
    > you want to delete this ? ')")
    >
    >
    > error:
    > Object reference not set to an instance of an object.
    >
    > btnDelete is a button inside another control called "ConfirmForm" but I
    > can't seem to find it to add the warning
    >
    > What's missing ??
    >
    David Kyle, Mar 7, 2005
    #2
    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. George Durzi

    OnEditCommand - .FindControl Returning Null

    George Durzi, Jul 14, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    478
    George Durzi
    Jul 14, 2003
  2. Ravikanth[MVP]

    FindControl

    Ravikanth[MVP], Jul 18, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    441
    Yan-Hong Huang[MSFT]
    Jul 22, 2003
  3. James G. Beldock
    Replies:
    1
    Views:
    9,301
    Kevin Spencer
    Aug 7, 2003
  4. Ivan Demkovitch
    Replies:
    1
    Views:
    809
    Ivan Demkovitch
    Oct 7, 2003
  5. ani

    FindControl method doesn't work

    ani, Nov 5, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    360
Loading...

Share This Page