Click here to Skip to main content
15,885,998 members
Articles / Programming Languages / C#
Article

Using C# controls in IE

Rate me:
Please Sign up or sign in to vote.
1.57/5 (17 votes)
13 Jun 2006 31.5K   540   19   6
An article on how to use C# controls in Internet Explorer

Sample Image - zrabai_article_1.jpg

Introduction

This article describes how you can use programmable C# controls in Internet Explorer without using IIS or other server program, but COM technology.

You have to place an object (identified by a classid) into the html code:

<body>>
    <object classid="clsid:32F9346E-D34A-47f3-8017-B62E7EEA6CB1">
    </object>
</body>

Use the same guid in the C# code of a Windows Control Library, and the following attributes before your own UserControl class. 
namespace UserControlInHtml
{
    [Guid("32F9346E-D34A-47f3-8017-B62E7EEA6CB1")]
    [ClassInterface(ClassInterfaceType.None)]
    [ProgId("UserControlInHtml.UserControl1")]
    public partial class UserControl1 : UserControl
    {
    ...
    }
}

Design your controls as usual. Before build process do not forget about two check boxes:
In Assembly Information dialog check the check box for "Make assembly COM-Visible" (Properties / Application tag).
On Properties / Build tag check the check box for "Register for COM interop".

After building open your html file from IE. Using Demo project you have to register before starting IE, see the attached readme.txt file.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here



Comments and Discussions

 
GeneralMy vote of 1 Pin
Nagy Vilmos23-Feb-09 2:28
professionalNagy Vilmos23-Feb-09 2:28 
QuestionRun Time Add Controls On Browser Pin
Sarita Rajput24-Jul-08 0:12
Sarita Rajput24-Jul-08 0:12 
AnswerRe: Run Time Add Controls On Browser Pin
Zolador24-Jul-08 4:52
Zolador24-Jul-08 4:52 
QuestionDo you know how to do it with C++ ? Pin
Marcello13-Jun-06 4:23
Marcello13-Jun-06 4:23 
AnswerRe: Do you know how to do it with C++ ? Pin
Zoltan2313-Jun-06 20:25
Zoltan2313-Jun-06 20:25 
QuestionSecurity Context Pin
Thomas Lykke Petersen29-May-06 21:34
Thomas Lykke Petersen29-May-06 21:34 
Hi
I am curious as to under which security context the OBJECT will run, I mean, will it be possible to make a socket connection back to the server (the same server which hosts the page) just as you can do with a java applet?

To my knowledge this will still require the client accessing the page with the hosted C# control to have the .NET runtime installed. Correct?

Regards,
Thomas Lykke Petersen (MCP)

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.