Back to Devexpress

HtmlContentControl.FindElementById(String) Method

windowsforms-devexpress-dot-xtraeditors-dot-htmlcontentcontrol-dot-findelementbyid-x28-system-dot-string-x29.md

latest3.1 KB
Original Source

HtmlContentControl.FindElementById(String) Method

Returns an HTML element with the specified ID.

Namespace : DevExpress.XtraEditors

Assembly : DevExpress.XtraEditors.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
public DxHtmlElement FindElementById(
    string id
)
vb
Public Function FindElementById(
    id As String
) As DxHtmlElement

Parameters

NameTypeDescription
idString

The ID of an element to be retrieved.

|

Returns

TypeDescription
DxHtmlElement

The element that has the specified ID.

|

Remarks

You can use the ‘id’ attribute to specify an HTML element’s ID in HTML markup:

html
<div id="photo">Photo</div>

The FindElementById method allows you to retrieve an HTML element with the specified ID in code. A DxHtmlElement object returned by this method exposes properties that you can use to change element display settings. The main properties include:

  • element.Hidden — Allows you to hide the element.

  • element.Style — Allows you to modify CSS style properties applied to the element. This object exposes the SetBackgroundColor, SetForeColor, and SetProperty methods for this purpose.

  • C#

  • VB.NET

csharp
var photo = htmlContentControl1.FindElementById("photo");
if (photo != null) photo.Hidden = true;
vb
Dim photo = htmlContentControl1.FindElementById("photo")
If photo IsNot Nothing Then
    photo.Hidden = True
End If

See the following topic for information on how to customize HTML elements with a specific ID in CSS code: CSS Styles - Id Selector.

See Also

FindElementsByClass(String)

FindElementsByTag(String)

FocusElement

ForEach(Action<DxHtmlElement>, Predicate<DxHtmlElement>)

HtmlContentControl Class

HtmlContentControl Members

DevExpress.XtraEditors Namespace