user2864496
user2864496

Reputation: 107

Finding all control and subcontrol ids present in aspx page and corresponding ascx user control

I am working on an application for this I have to access all the control ids in the aspx page by using jquery. I am looking for a way so that I can access all these control ids that are present. I should also be able to access subcontrol ids and I am using usercontorls which are written in ascx pages that are referred in aspx. I want a way using jquery to access all the control ids which are present in current aspx page, cotrols present in ascx page corresponding to the aspx page and Ids of the sub controls also. I want to access labels ids, textbox ids even if they are specified inside table or div. Please suggest me a way

Upvotes: 1

Views: 646

Answers (2)

user2864496
user2864496

Reputation: 107

I used common class name to access all the grid views in the project and thus I was able to access each and every header and tr and td's of the grid view.

I made sure that all grid views will have common class name. I accessed dropdown by using $('select') and check box and label by using $("span") because they are fetched correspondingly in the html page. Then I wrote corresponding jQuery code to do the things I wanted like hover and each eg:

$('select').hover ()

Upvotes: 0

Ved Singhal
Ved Singhal

Reputation: 86

The best way I can think of to answer this is to make a custom jquery plugin to do this:

jQuery.fn.getIdArray = function() {
  var ret = [];
  $('[id]', this).each(function() {
    ret.push(this.id);
  });
  return ret;
};

Then do something like

var array = $("#mydiv").getIdArray();

Upvotes: 1

Related Questions