Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
290
How to access Child controls via Javascript
posted

Could somoen help:

I have an existing web page that I have recently added an Infragistics WebTab to. I have moved all my asp.net controls

to tab 1 of the webtab control. Everythings works fine, and I love the control other than I can no longer access a textbox

via javascript which is now contained within tab1 of the webtab control.

My javascript is contained within a linked JScript.js file. I used to be able to do the following.

document.getElementById('txtCustomer').value = 'This is some text'; But now I'm getting the following error

"Microsoft JScript runtime error: Unable to set value of the property 'value': object is null or undefined". I am guessing

it's because the control is now a child of the WebTab control

 

How do you access a child control of a Infragistics WebTab control via Javascript?

 

Any help would be appreaciated.

 

Thanks

Dave.

Parents
  • 8421
    posted

    Hello Dave,

    When you place controls inside of the tab the ids will be changed dynamically to avoid conflicts if there are controls with the same name used on different tabs.  The same thing happens for UserControls and ContentPlaceholders on a master page.

    As such, the id being passed into document.getElementById will need to be modified.  The best way to accomplish this is to use the ClientID of the server side control:

    document.getElementById('<%= txtCustomer.ClientID %>')

    I've attached a small sample that demonstrates how the ClientID is formed along with how to use the code block to access a control inside of a tab.

    Please let me know if I can be of any further assistance.

    WebTabGetControl.zip
Reply Children