Link to home
Start Free TrialLog in
Avatar of haveabun
haveabunFlag for Sweden

asked on

Finding control in AJAX updatepanel using Javascript?

Hi!

I have a asp.net 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!
Avatar of divinewind80
divinewind80

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...
Avatar of haveabun

ASKER

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?
ASKER CERTIFIED SOLUTION
Avatar of divinewind80
divinewind80

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
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.
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.