Child Control ID Problem

Discussion in 'ASP .Net Web Controls' started by Ashish Kaila, Oct 25, 2004.

  1. Ashish Kaila

    Ashish Kaila Guest

    Hello All,
    I am having trouble with client side events in a composite webcontrol.
    Basically when I add a button as a child, setting its id as Button_0_0, the
    html source adds the <controlid>_ in front of the actual Button_0_0 id. Now
    when the postback occurs from Button_0_0, the id recieved in OnBubbleEvent
    is Button_0_0 but when I try to add a client script from a link control
    referencing Button_0_0 or <controlid>_Button_0_0 javascript reports an error
    saying object not found. Anyone has any clue of whats going wrong ?
    Thanks,
    Ashish Kaila
     
    Ashish Kaila, Oct 25, 2004
    #1
    1. Advertising

  2. Ashish Kaila

    Drew Robbins Guest

    You can use the control's ClientID property to reference the control in
    client script. The ClientID is the identifier as it is assigned to the
    HTML control in the page output.

    Ashish Kaila wrote:
    > Hello All,
    > I am having trouble with client side events in a composite webcontrol.
    > Basically when I add a button as a child, setting its id as Button_0_0, the
    > html source adds the <controlid>_ in front of the actual Button_0_0 id. Now
    > when the postback occurs from Button_0_0, the id recieved in OnBubbleEvent
    > is Button_0_0 but when I try to add a client script from a link control
    > referencing Button_0_0 or <controlid>_Button_0_0 javascript reports an error
    > saying object not found. Anyone has any clue of whats going wrong ?
    > Thanks,
    > Ashish Kaila
    >
    >
     
    Drew Robbins, Oct 25, 2004
    #2
    1. Advertising

  3. Ashish Kaila

    Ashish Kaila Guest

    Doesnt work... Does not recog. control by its id.
    Ashish

    "Ashish Kaila" <> wrote in message
    news:...
    > Hello All,
    > I am having trouble with client side events in a composite webcontrol.
    > Basically when I add a button as a child, setting its id as Button_0_0,

    the
    > html source adds the <controlid>_ in front of the actual Button_0_0 id.

    Now
    > when the postback occurs from Button_0_0, the id recieved in OnBubbleEvent
    > is Button_0_0 but when I try to add a client script from a link control
    > referencing Button_0_0 or <controlid>_Button_0_0 javascript reports an

    error
    > saying object not found. Anyone has any clue of whats going wrong ?
    > Thanks,
    > Ashish Kaila
    >
    >
     
    Ashish Kaila, Oct 26, 2004
    #3
  4. Ashish Kaila

    Drew Robbins Guest

    How are you trying to access the control? I typically use something like
    the following javascript to get a reference to the control...

    var controlElement = document.getElementById('<Control.ClientID>');

    Replace the <Control.ClientID> token with the string returned from your
    control's ClientID property.

    Ashish Kaila wrote:
    > Doesnt work... Does not recog. control by its id.
    > Ashish
    >
    > "Ashish Kaila" <> wrote in message
    > news:...
    >
    >>Hello All,
    >>I am having trouble with client side events in a composite webcontrol.
    >>Basically when I add a button as a child, setting its id as Button_0_0,

    >
    > the
    >
    >>html source adds the <controlid>_ in front of the actual Button_0_0 id.

    >
    > Now
    >
    >>when the postback occurs from Button_0_0, the id recieved in OnBubbleEvent
    >>is Button_0_0 but when I try to add a client script from a link control
    >>referencing Button_0_0 or <controlid>_Button_0_0 javascript reports an

    >
    > error
    >
    >>saying object not found. Anyone has any clue of whats going wrong ?
    >>Thanks,
    >>Ashish Kaila
    >>
    >>

    >
    >
    >
     
    Drew Robbins, Oct 26, 2004
    #4
    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. bhchng
    Replies:
    0
    Views:
    661
    bhchng
    Jan 13, 2004
  2. Bryan Ax
    Replies:
    6
    Views:
    548
    Peter Flynn
    May 17, 2006
  3. Jeff Rodriguez
    Replies:
    23
    Views:
    1,132
    David Schwartz
    Dec 9, 2003
  4. caldera

    Placeholder child of child control event problem.

    caldera, May 27, 2004, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    214
  5. Replies:
    0
    Views:
    210
Loading...

Share This Page