Create HTML using HtmlTextWriter class in x++

HtmlTextWriter class is used to output properly formed HTML
into a web page.  The
HtmlTextWriter allows the developer to code attributes, style attributes, and
tags etc.

The HtmlTextWriter class permits the developer to generate
page output in a non-browser specific way; that is to say, the burden of
developing alternative markup is typically removed by using the
HtmlTextWriter.  The HtmlTextWriter class exposes properties, fields, and
methods that permit the developer to format HTML 4.0 compliant output. 

For example, in the job below i  added static string and  an image using the HtmlTextWriter class.

static void HTMLTextWriter(Args _args)


    HTMLTextWriter htw = new HTMLTextWriter();

    TextBuffer     txtBuffer = new TextBuffer();

    CCHTMLString   staticString;


    staticString = @’At
Solugenix we know our success results from taking a long term view in all

    our relationships: clients,
employees, industries and technologies.’;




htw.addAttribute(HtmlTextWriterAttribute::class_Attribute(), ‘ms-vb’);

htw.addStyleAttribute(HtmlTextWriterStyle::width(), ’26px’);

htw.addStyleAttribute(HtmlTextWriterStyle::padding_top(), ‘3px’);


htw.addAttribute(HtmlTextWriterAttribute::src(), ‘’);//get
the image from web

htw.addStyleAttribute(HtmlTextWriterStyle::width(), ‘100’);

htw.addStyleAttribute(HtmlTextWriterStyle::height(), ’50’);

htw.renderBeginTag(HtmlTextWriterTag::img(), true);

//close <Td>

//close <Table>


txtBuffer.toFile(‘f:\\DynamicsAX.html’);  // please provide your path to save the


The result of the above code will be –


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: