0

I have user control in which there are text boxes no i am using the AJAX to populate the child controls dynamically however asp.net appending some string to child controls causing problems to write the JavaScript code.
Though i have tried getElementLike('key') which iterate elements and get the right one for me but this is really inefficient. So if anybody has any insight on this issue please provide you input/suggestions.
Thanks all,

1
  • Can we see some of your code along with some of the resultant code from view->source ? Commented Jan 28, 2010 at 15:19

3 Answers 3

3

You will need to refer to those controls like this:

// typical way
var element1 = document.getElementById("<%= control.ClientID %>");
// jquery way
var element2 = $("#<%= control.ClientID %>");
Sign up to request clarification or add additional context in comments.

Comments

1

Look at using someControl.ClientId, which will give you the ASP.NET generated id of the control. Using this Id you will be able to correctly target the element via javascript.

Comments

0

Use jquery to select the item using something like $("[id$='CWRCompanyId']"), this basically looks for id's that end with your expected ID.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.