This article demonstrates how to update the attribute value of the specified element by the element Id.

С#

using System;
using DotNetBrowser;
using DotNetBrowser.DOM;

namespace UpdatingAttributes
{
    class Program
    {
        //The browser instance
        private static Browser browser;

        static void Main(string[] args)
        {
            //Create browser
            browser = BrowserFactory.Create();

            //Load HTML content
            browser.LoadHTML("<html>" +
                             "<head></head>" +
                             "<body>" +
                                "<div id=\"block_with_background\" style=\"background-color: red;\">" +
                                        "Block with background" +
                                "</div>" +
                             "</body></html>");

            //Wait until the main frame is loaded
            browser.FinishLoadingFrameEvent += (sender, eventArgs) =>
            {
                if (eventArgs.IsMainFrame)
                {
                    //Get the document and the required element
                    DOMDocument document = browser.GetDocument();
                    DOMElement divWithBackground = document.GetElementById("block_with_background");

                    //Get and print the current value of the element's 'style' attribute
                    string styleValue = divWithBackground.GetAttribute("style");
                    Console.WriteLine(styleValue);

                    //Set the new value for the 'style' attribute
                    divWithBackground.SetAttribute("style", "background-color: blue;");

                    //Get and print the new value of the element's 'style' attribute
                    styleValue = divWithBackground.GetAttribute("style");
                    Console.WriteLine(styleValue);
                }
            };

            Console.ReadKey();
        }
    }
}

VB.NET

Imports DotNetBrowser
Imports DotNetBrowser.DOM

Module Module1
    Private Dim browser As Browser

    Sub Main()
        'Create browser
        browser = BrowserFactory.Create()

        'Load HTML content
        browser.LoadHTML("<html>" +
                         "<head></head>" +
                         "<body>" +
                         "<div id=""block_with_background"" style=""background-color: red;"">" +
                         "Block with background" +
                         "</div>" +
                         "</body></html>")

        'Wait until the main frame is loaded
        AddHandler browser.FinishLoadingFrameEvent,
            Sub(o, eventArgs)
                If eventArgs.IsMainFrame Then
                    'Get the document and the required element
                    Dim document As DOMDocument = eventArgs.Browser.GetDocument()
                    Dim divWithBackground As DOMElement = document.GetElementById("block_with_background")

                    'Get and print the current value of the element's 'style' attribute
                    Dim styleValue As String = divWithBackground.GetAttribute("style")
                    Console.WriteLine(styleValue)

                    'Set the new value for the 'style' attribute
                    divWithBackground.SetAttribute("style", "background-color: blue;")

                    'Get and print the new value of the element's 'style' attribute
                    styleValue = divWithBackground.GetAttribute("style")
                    Console.WriteLine(styleValue)

                End If
            End sub

        Console.ReadKey()
    End Sub
End Module