PPienaar PPienaar - 6 months ago 26
HTML Question

HTML embedding in c# form application

I've recently started to use a e-commerce cart online, and wanted to make a app. But they gave me a HTML code snippet that I can embed in my own website, that I have. But is there a way I can embed this into my c# form application, and a Android Studio application?
Kind Regards


You need to first complete the HTML. The code you've shown is just div and script. You can't add it to your webBrowser because it's not valid HTML.

Complete the HTML

    <title>My Win Forms App<title>
    <div id="my-store-></div>
        <script type="text/javascript" src="https://app.ecwid.com/script.js?&data_platform=code&data_date=" charset="utf-8">
        <script type="text/javascript"> xProductBrowser("categoriesPerRow=3","views=grid(3,3) list(10) table(20)","categoryView=grid","searchView=list","id=my-store-");

Without these <body> <head> <HTML> tags you don't have a complete HTML document.

Then you can either do this as a string, or target the ".HTML" source file. Or, or, or. This has quite a bit of flexibility. See here for the MSDN info on the WebBrowser class.

As this article describes:

// make your string
string myHTML = "<html>...</html>";

WebBrowser wb = new WebBrowser(); //make you WebBrowser instance

wb.DocumentText = myHTML; //set your HTML
wb.DocmentText = "<html>...</html>";  // you can also do a direct assignment