Skip to content

Display large html with CSS. #4915

Closed
Closed

Description

@itg-assistant

Adrian Zagar asked 2025-12-08 12:18:06 UTC

Hi,

I have a string html that contains a large html including CSS for a sticky menu and a "back to top" button".
If I want to display it in a different page, it works perfectly with code:

byte[] bytes = System.Text.Encoding.UTF8.GetBytes(htmlContent);
using (MemoryStream ms = new MemoryStream(bytes))
{
Application.DownloadAndOpen("blank", ms, $"catalog{dataValabilitate}.html");
}

But now I want to display it and replace my application page. I tried with
var p1 = new Page();
var h = new HtmlPanel();
h.Html = html;
h.Dock = DockStyle.Fill;
p1.Controls.Add(h);
p1.Show();
It is displayed, but all button/menu functions are inactive.
In css I have something like
.back-top {
position: fixed;
bottom: 20px;
left: 25px;
background: #3498db;
color: white;
padding: 10px 20px;
border-radius: 50%;
font-size: 18px;
box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.back-top:hover {
background: #2c3e50;
}
....
and in html ↑

Any way to activate CSS actions? Or to display my html instead of application page?

Activity

  1. itg-assistant commented on Jun 17, 2026

    @itg-assistant
    Author

    Julie (ITG) answered 2025-12-08 17:43:20 UTC

    The HtmlPanel control in Wisej.NET is designed to display HTML content, but it doesn't create a full browser environment. Instead, it renders HTML within Wisej’s own widget framework. Because of this, CSS pseudo-classes like :hover still work correctly, since they are handled by the browser. However, anchor links such as do not behave as they normally would, because HtmlPanel does not create a standard browsing context with typical navigation. In addition, any JavaScript included in your HTML will not be executed.

    If you want to display the HTML within your application while keeping the app active, use IFramePanel or WebBrowser control. These create a real iframe/browser context where CSS and anchor links work properly.

  2. itg-assistant commented on Jun 17, 2026

    @itg-assistant
    Author

    Adrian Zagar answered 2025-12-10 09:08:38 UTC

    Hi Julie,

    What I need is that: when specific conditions are met (in parameters, etc; doesn't concern the topic), I need one of the 2 posibilities:

    1. Display the full html (with css, etc) in a webbrowser control. But I wasn't able to find HOW to execute something like
      WebBrowser wb;
      wb.html=myHtml; //that doesn't exist; what can I do?

    2. Completely replace my application with myHtml. I tried:
      byte[] bytes = System.Text.Encoding.UTF8.GetBytes(html);
      using (MemoryStream ms = new MemoryStream(bytes))
      {
      Application.DownloadAndOpen("_blank", ms, $"catalog.html");
      }
      Application.Navigate("javascript:window.close();");

    That works, but the browser display a warning "allow pop-up" or "pop-up blocked" that prevent the opening of the new tab.

    The first approach will be better, if you can tell me how to "inject" all html in WebBrowser.

  3. itg-assistant commented on Jun 17, 2026

    @itg-assistant
    Author

    Julie (ITG) answered 2025-12-10 15:16:41 UTC

    You can do the first approach like this:

    string myHtml = "Hello";
    string base64Html = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(myHtml));
    webBrowser1.Url = new Uri($"data:text/html;base64,{base64Html}");
    

    For the second approach, you can create an endpoint/handler that returns your HTML and navigate to it:
    Application.Navigate("/api/catalog?id=123");

  4. itg-assistant commented on Jun 17, 2026

    @itg-assistant
    Author

    Adrian Zagar answered 2025-12-10 16:29:56 UTC

    Thank you for answer. Unfortunatelly, myHTML is too big to use that method. If you khow another method, please advice.
    Please give more details on second approach, seems interesting!

  5. itg-assistant commented on Jun 17, 2026

    @itg-assistant
    Author

    JD answered 2025-12-10 17:12:42 UTC

    Just navigate to the html file and let the browser do the work.

  6. itg-assistant commented on Jun 17, 2026

    @itg-assistant
    Author

    JD answered 2025-12-10 17:14:37 UTC

    In your sample you are using the wrong target.

  7. itg-assistant commented on Jun 17, 2026

    @itg-assistant
    Author

    Adrian Zagar answered 2025-12-10 17:18:00 UTC

    “Just navigate to the html file and let the browser do the work.” – please elaborate. Application.DownloadAndOpen(“_blank”, ms, $”catalog.html”); is opening a popu-up (new tab) in browser, serving the html as source. Opening pop-ups is tricky because of the browser asking for permision.

  8. itg-assistant commented on Jun 17, 2026

    @itg-assistant
    Author

    Julie (ITG) answered 2025-12-15 15:34:16 UTC

    Using Application.Navigate to access the html file is pretty simple.

    Simply add the html file to your project, ie myhtml.html.

    Then access it with Application.Navigate.

    Application.Navigate(“myhtml.html")
    

    See attached test case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    GeneralQuestions, how-tos and everything else.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions