.Net 2.0 WebBrowser Control DesignMode = "On"

Has anyone been able to get WebBrowser1.DesignMode = "On" to work with the .net 2.0 WebBrowser Control Usally this is a wrapper around the mshtml control. Like the following, but I couldn't find a solution with the .Net 2.0 Webbrowser control.

doc = WebBrowser1.Document
doc.DesignMode = "On"


Cheers, Patrick

It's been a few days without any replies, are there other people looking for this solutions as well If so lets start talking..




Answer this question

.Net 2.0 WebBrowser Control DesignMode = "On"

  • Paul Bronowski

    Try this.

    webBrowser1.Document.Body.SetAttribute("contenteditable", "true");

  • lmsa

    I found the following code, but was unable to get it to work, as anyone else attempted this < xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />



    http://weblogs.asp.net/hpreishuber/archive/2005/07/13/419281.aspx


  • speed2002

    In C# you would need to call .ActiveXInstance.GetType().GetProperty("DesignMode").SetValue(doc.ActiveXInstance, "On");

     


  • Dya

    Thanks you!!! This worked on the first try! This is very much appreciated. I have searched most of the internet for this solution with no solution.

    < xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> 

    Thank you again.



  • nagajim

    I'm tring to set the designMode property of the Webbrowser .Net 2.0 control the following code works great on Windows XP Pro, Windows 2000 Server, but I have 2 computers. Where the PropertyInfo object is null, I tried the following with the

    ....

    Webbrowser = new Webbrowser ();
    ....

    Webbrowser.documentcompleted = OnDocumentCompleteGetEditor;

    OnDocumentCompleteGetEditor (.... )
       {
       Type Type;
       PropertyInfo PropertyInfo;
       Type    = Webbrowser.Document.DomDocument.GetType();

       // PropertyInfo is null on Windows 2003 Server and on
       // Windows 2000 Desktop
       // PropertInfo below is null, but if you have the SDK installed, you'll get a
       // complete list of Properties, is the a BUG Why would the SDK make 
       // diffence
       PropertyInfo = Type.GetProperty("designMode"); // is null
       PropertyInfo.SetValue(base.Document.DomDocument, "On", null);
       }

    My propertyInfo is null so Set.Value crashes, can anyone reproduce this problem or can someone explain the proper way of setting the designMode= "On";



  • tmstewart

    I've tried the following but have always got this error when I compling, I noticed that OptionExplicit is a VB command, is there a c# version of this

    Webbrowser.CS(36,25): error CS0117: 'object' does not contain a definition for 'Document'

  • PabloTola

    WebBrowser wb = new WebBrowser();

    Controls.Add(wb);

    wb.DocumentCompleted += delegate

    { wb.Document.DomDocument.GetType().GetProperty("designMode").SetValue(wb.Document.DomDocument, "On", null);};

    wb.DocumentText = "";


  • Ranjeeta

    I noticed the same problem with the properties not being present without the SDK being installed.  I found another way to enter into design mode using the ActiveXInstance property of the WebBrowser control.  This works without the SDK.  The only catch is that Option Explicit must be set to Off.

      WebBrowser1.ActiveXInstance.Document.designMode = "On";


  • .Net 2.0 WebBrowser Control DesignMode = "On"