Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
rated 0 times [  167] [ 1]  / answers: 1 / hits: 102498  / 16 Years ago, fri, march 13, 2009, 12:00:00

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.

More From »


Oh, and I also found this, in case anyone else is having this problem.

Use a custom jQuery selector for controls:

[#99854] Friday, March 6, 2009, 16 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.

Total Points: 295
Total Questions: 106
Total Answers: 104

Location: Angola
Member since Wed, Apr 13, 2022
2 Years ago
anders questions
Thu, Feb 18, 21, 00:00, 3 Years ago
Thu, Sep 17, 20, 00:00, 4 Years ago
Mon, Jun 29, 20, 00:00, 4 Years ago
Tue, Apr 7, 20, 00:00, 4 Years ago