Organizational Research By

Surprising Reserch Topic

reference asp net control by id in javascript


reference asp net control by id in javascript  using -'javascript,asp.net,ajax'

When ASP.NET controls are rendered their ids sometimes change, like if they are in a naming container. Button1 may actually have an id of ctl00_ContentMain_Button1 when it is rendered, for example.

I know that you can write your JavaScript as strings in your .cs file, get the control's clientID and inject the script into your page using clientscript, but is there a way that you can reference a control directly from JavaScript using ASP.NET Ajax?

I have found that writing a function to parse the dom recursively and find a control that CONTAINS the id that I want is unreliable, so I was looking for a best practice rather than a work-around.
    

asked Sep 13, 2015 by JesMathew
0 votes
16 views



Related Hot Questions

8 Answers

0 votes
NULL
answered Sep 13, 2015 by KishaK67qavr
0 votes
NULL
answered Sep 13, 2015 by PDLMariisxol
0 votes
NULL
answered Sep 13, 2015 by ScottyRobiso
0 votes
NULL
answered Sep 13, 2015 by LeliaOdomsq
0 votes
NULL
answered Sep 13, 2015 by MillaP56bdd
0 votes
NULL
answered Sep 13, 2015 by BuckHaileyvo
0 votes
NULL
answered Sep 13, 2015 by ThomasIFLAde
0 votes
NULL
answered Sep 13, 2015 by Zak9370

...