This is a migrated thread and some comments may be shown as answers.

HtmlTableCell childnodes find item collection

1 Answer 82 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Veteran
Iron
Andrew asked on 21 Oct 2010, 03:13 PM
I want to find the first occurrence of a image control in the childnodes collection
currently I am just looping through till I find the first one with a tagname of "img"

is there a better way to do this?

also is it possible to cast/convert an element to its htmlobject ex: img element to HtmlImage?

1 Answer, 1 is accepted

Sort by
0
Cody
Telerik team
answered on 01 Nov 2010, 08:49 PM
Hi Andrew,

To find the first <img> child node you can use code like this:

ReadOnlyCollection<HtmlImage> images = cell.Find.AllByTagName<HtmlImage>("img");
HtmlImage firstImage = images[0];

This code assumes "cell" is of type HtmlTableCell.

To case a base Element to an Html object type use the .As<> function like this:
HtmlDiv divElem = elem.As<HtmlDiv>();


Greetings,
Cody
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
General Discussions
Asked by
Andrew
Top achievements
Rank 1
Veteran
Iron
Answers by
Cody
Telerik team
Share this question
or