We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to change the characteristic of an element before it is being displayed using the prerender document event of the HTMLUI control?

Platform: WinForms |
Control: HTMLUIControl |
Published Date: April 30, 2011 |
Last Revised Date: July 10, 2014

 

The Characteristic of an element can be easily changed in the PrerenderDocument Event of the HTMLUI control.

The Prerenderdocument event is raised when the elements in the HTML document are created in the HTMLUI control but their size and location are not calculated yet.

This event is used to change the characteristics of the element before they are positioned in the HTMLUI control.

The following snippet shows how an image reference is changed for a page in the HTMLUI at run time in the PrerenderDocument Event.

C#

[HTML]

C#

Hashtable htmlelements = new Hashtable();

this.htmluiControl1.PreRenderDocument += new Syncfusion.Windows.Forms.HTMLUI.PreRenderDocumentEventHandler(this.htmluiControl1_PreRenderDocument);

private void htmluiControl1_PreRenderDocument(object sender,PreRenderDocumentArgs e)

{

this.htmlelements = e.Document.GetElementsByNameHash();

ArrayList imgs = this.htmlelements["img"] as ArrayList;

foreach(BaseElement elem in imgs)

{

string oldValue = elem.Attributes["src"].Value;

string newValue = e.Document.CurrentDirectory + "\\sync.jpg";

elem.Attributes["src"].Value = oldValue.Replace(elem.Attributes["src"].Value, newValue);

Console.WriteLine(elem.Attributes["src"].Value);

}

}

VB

Private htmlelements As Hashtable = New Hashtable()

Private Me.htmluiControl1.PreRenderDocument += New Syncfusion.Windows.Forms.HTMLUI.PreRenderDocumentEventHandler(Me.htmluiControl1 _PreRenderDocument)

Private Sub htmluiControl1_PreRenderDocument(ByVal sender As Object, ByVal e As PreRenderDocumentArgs)

Me.htmlelements = e.Document.GetElementsByNameHash()

Dim imgs As ArrayList = CType(IIf(TypeOf Me.htmlelements("img") Is ArrayList, Me.htmlelements("img"), Nothing), ArrayList)

For Each elem As BaseElement In imgs

Dim oldValue As String = elem.Attributes("src").Value

Dim newValue As String = e.Document.CurrentDirectory & "\sync.jpg"

elem.Attributes("src").Value = oldValue.Replace(elem.Attributes("src").Value, newValue)

Console.WriteLine(elem.Attributes("src").Value)

Next elem

End Sub

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon