locked
How to let WebBrowser reference to resources (css/js files) RRS feed

  • Question

  • Hello,

    The title of the thread actually describes the whole question.

    I got a WebBrowser object inside my WindowsForms Application with the following HTML:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
        <title></title>
        <link href="style.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
        Test!!
    </body>
    </html>

    However, style.css is an internal resource in resources.resx. I don't want to unpack the files over and over again, nor do I want to "install" them on my clients computer.So, how to reference properly to them?


    Regards, MusicDemon


    • Edited by MusicDemon Wednesday, July 25, 2012 9:53 PM
    • Moved by Bob Shen Friday, August 3, 2012 2:34 PM (From:Visual C# Language)
    Wednesday, July 25, 2012 9:51 PM

All replies

  • maybe you need to write the styles to the controls in the same class file, instead of calling a separate cs file.

    http://stackoverflow.com/questions/499743/webbrowser-controls-window-external-is-always-null

    http://stackoverflow.com/questions/2562297/c-sharp-webbrowser-control-not-applying-css

    regards

    joon

    Thursday, July 26, 2012 8:46 AM
  • The second link has some potential...

    But, with other words, it's not possible to have a simple src="(...)/style.css", you must know the whole HTML page at development-time to add the stylesheets/javascript file/images?

    If that is the case then, how to use the FileDownload Event? I can't find any reference to the file it wants to download.


    Regards, MusicDemon


    • Edited by MusicDemon Thursday, July 26, 2012 9:26 AM
    Thursday, July 26, 2012 9:24 AM
  • if you are looking for webbrowser file download event, http://social.msdn.microsoft.com/Forums/en/Vsexpressvb/thread/92416007-8ddf-4dd6-b904-5a8b0aa42f28

    i guess, in winform app, when webbrowser is used - it has limitation. Say in web app, we can navigate to source folder with double dots(..) or slash(/), which maybe winform does not understand. So maybe custom code in C# would be nice to handle styles. For scripts, as you know in winform we use messagebox in place of javascript alert(as an example). so there wil be be difference.

    regards

    joon

    Thursday, July 26, 2012 10:37 AM
  • The event is triggered by the WebBroweser object itself, being able to even read which file it wants to download and being able to send a packet/stream back would already do the thing. It it doesn't work the easy way...

    Regards, MusicDemon

    Thursday, July 26, 2012 10:50 AM
  • The event is triggered by the WebBroweser object itself, being able to even read which file it wants to download and being able to send a packet/stream back would already do the thing. It it doesn't work the easy way...

    Regards, MusicDemon

    yes, you are correct. it is associated with the control itself. Is it something else you are looking for in this control?

    regards

    joon

    Thursday, July 26, 2012 10:55 AM
  • Well, as far as I can see, it's way too limited to do any major things with it...

    My idea was to use the WebBrowser to let others help me with designing.

    If there's someone else with any idea how the WebBrowser actually can do these kind of things, please reply.


    Regards, MusicDemon


    • Edited by MusicDemon Thursday, July 26, 2012 12:09 PM
    Thursday, July 26, 2012 11:08 AM
  • Hi MusicDemon,

    You can consider use this forum for better support. Thanks.

    http://forums.asp.net/


    Bob Shen [MSFT]
    MSDN Community Support | Feedback to us

    Friday, August 3, 2012 2:34 PM
  • Hello sir Shen,

    I'm not sure but, what would it have to do with ASP.Net? I mean the WebBrowser control as"System.Windows.Form.WebBrowser".


    Regards, MusicDemon

    Saturday, August 4, 2012 4:32 PM