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?


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.




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);





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)


Next elem

End Sub

Article ID: Published Date: Last Revised Date: Platform: Control:
811 04/30/2011 07/10/2014 WinForms HTMLUIControl
Did you find this information helpful?
Add Comment
You must log in to leave a comment

Please sign in to access our KB

or the page will be automatically redirected to 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