About "C # applets"

Source: Internet
Author: User
Tags html page iis client brinkster
The following text comes from C # Expert,

I am wondering how to build a C # applet. I built a class library with a custom control. But the browser (IE6) fails to render it as object. Do your have some examples to show how to achieve this? By the way, can a C # applet be run under platforms without the. NET Framework pre-installed?

There ' s no such concept as a C # "applet". At most, there are custom Windows forms controls this are embedded on a page. Of course, just like in Java, and can ' t run it if you don ' t have the corresponding runtime on the client machine. can use the <object> tag to add it to a HTML page: (zzj0820 Note: There is actually no concept of the so-called C # applet, which is usually referred to as a form control embedded in the browser 。 Of course, like Java, the appropriate Run-time libraries must be installed on the client machine to use an object label control embedded in an HTML page.

<object id= "mycontrol" classid= "Http://mywebsite/MyClassLibrary.dll#FullNamespace.MyControlClass" height= "480" Width= "640" ></object>

The class ID contains the URL of the DLL for downloading and the fully qualified name of the class that implements the con Trol. The library must not is placed on The/bin folder of a WEB application in order to is served by iis/asp.net

Here are two simple examples that will help J

EG1: Original link

/*

* A simple C # program which displays some text in A webpage.

* Compile with: "Csc/t:library Hello-world-applet.cs"

* Run byte deploying in a webpage with:

* <object classid= "Http:hello-world-applet.dll#helloworldapplet" width= "height=" ></object>

* Ben Bederson, January 16, 2002

*/

Using System;

Using System.Drawing;

Using System.Windows.Forms;

public class HelloWorldApplet:System.Windows.Forms.Control {

Public Helloworldapplet () {

Create a "label" control

Label label = new label ();

Label. Text = "Hello world!";

Label. ForeColor = Color.Blue;

Label. Font = new Font ("Arial", fontstyle.bold);

Label. AutoSize = true;

Insert the label

Controls.Add (label);

}

}

EG2: Original link

C # applets
by Lloyd Dupont

I want to tell you the I-write C # Applet, display it in a Web page and the requirement.

The requirement-your C # Applet won ' t work anywhere nor from anywhere. Should put (and test) it in IIS, for unknown reason (in last unknown to me) This won ' t work locally or with Apache. BTW http://www.brinkster.com make free ". NET" Hosting.

Not any client could display a C # Applet, surely need IE6 and probably. NET SDK (at last with these configuration Work everywhere I know).

After your wrote your custom System.Windows.Forms.Control, create it with a parameterless constructor (which'll be called by IE) and wrap it in a assembly.

After you could display it very easily the Web page like this:

<object

Id=anid

Classid= "Http:myassemblydll.dll#controlclasstoinstantiate"

height=300 width=300>

</object>

And with ID your could call it public to vis javascript like this

<script> <!--

Myid.aproperty = Avalue;

Myid.refresh ()

--></script>

This is a example you could to http://www24.brinkster.com/superlloyd/un.htm

--un.html--



<title>c# Web Control i</title>


<body>

and now...<br>

<object id=t

Classid= "HTTP:UN.DLL#WT. T

height=300 width=300 viewastext>

</object>

<br>

<a href=un.cs>source</a>

</body>


--Un.cs--

Using System;

Using System.Drawing;

Using System.Windows.Forms;

CSC Un.cs

Csc/t:library/out:un.dll Un.cs

Namespace WT

{

public class T:control

{

protected override void OnPaint (PaintEventArgs e)

{

E.graphics.fillrectangle (New SolidBrush (color.azure), clientrectangle);

E.graphics.drawline (Pens.darksalmon,

New Point (0, 0),

New Point (Clientrectangle.width, clientrectangle.height));

}

public static void Main (string[] m)

{

Form f = new form ();

T t = new t ();

T.dock = DockStyle.Fill;

F.controls.add (t);

Application.Run (f);

}

}




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.