Finding control in AJAX updatepanel using Javascript?


I have a application with a dropdownlist and a textbox within an updatepanel. Depending on what is selected in the dropdownlist, the textbox will be shown or not using AJAX. I would like to find the Textbox control using Javascript when it is shown. The Textbox is drawn on the screen, but when I view the HTML source code, I can't find the control unless I reload the Page.  This probably has something to do with using AJAX, but it must be drawn somewhere if it is shown on the screen. I am quite new at both Javascript and AJAX so I hope someone could help, thanks!
Who is Participating?
divinewind80Connect With a Mentor Commented:
Well, in my experience, I have always had trouble when combining an UpdatePanel and Javascript.  Perhaps someone else has a comment on it, but I would suggest that you use the AJAX autocomplete if you are wishing to use Javascript.  Otherwise, if you are using Javascript for client-side activity, why do you need the UpdatePanel?  Have you considered switching the server-side events to client-side and doing everything but the (assuming you need one) postback through Javascript?
What exactly are you wanting to do with the textbox in Javascript?  The reason I am asking is that you can do a fair amount of the same things by using the UpdatePanel without a postback...
haveabunAuthor Commented:
Hi, thanks for you're reply.
We have a javascript code which has an autocomplete functionality we would like to use. I know there is an Ajax autocomplete but because of some functions we use in the javascript autocomplete, and we use this in other places in the application which do not use AJAX. We would like to keep it consistent with other parts. If possible we would like to avoid doing a postback to find the control. Is it possible?
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

haveabunAuthor Commented:
Thank you, I understand you're thoughts, but the customer want's the Javascript functionality there as well, and for consistency we did not want to have an AJAX version.
Had I built this from scratch I would never done it like this, but the update panel and Javascript was developed in different parts of the development. I have not developed the updatepanel, and it seems it is used for different both server and client side events, depending what you are looking at.
I thought it would have been an easy solution using the Javascript, but I was wrong. I'll look for another solution, but it seems we need to suggest the AJAX version to do this anyway, if someone does not have a solution to this?
I will just have to make it look like the Javascript version.
haveabunAuthor Commented:
Does not seem like anyone has an answer to my original question, so I rebuild the usercontrol instead of just adding some code to make tha changes work. And the javascript works now, on a closer look, the updatepanel was not really needed at all! Thanks for you're replies divinewind80, I took you're advise to look over the code an rebuild it so I have accepted you're solution.
haveabunAuthor Commented:
The solution was not really what I was looking for in the first place, but it pointed me in another direction, that I probably would have gone anyway if I did not get an answer. But with the answer from an expert I know that there is not an easy answer to the question.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.