Library tutorials & articles
.NET Applets
- Introduction
- To The Code!
- The HTML Code
The HTML Code
For simplicity's sake, create a Web Project. In your default page put a tag like this:
<object id='ControlID' classID='PathToAssemblyFile.dll#Qualified.Class.Name' />
Place the complied DLL from your control project in the same virtual directory as the HTML. Then browse to it. Your control should pop up. As you select the items, the label should change. You have just created a .NET Applet. (Note: If you run this from the local machine or an Intranet Webserver you will not be as restricted as a control run from the Internet zone. Keep this in mind when your users say it's not working out of the office.) Here's an example of the html:
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="demoPage.aspx.vb" Inherits="demoWebProj.demoPage" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>Cropping an Image</title>
</HEAD>
<body id="bdyElem" runat="server">
<form id="Form1" runat="server">
<OBJECT id="myControl" height="620" width="500" classid="PathToAssemblyFile.dll#Qualified.Class.Name'
viewastext>
<PARAM NAME="value1" VALUE="<%# dynamicValue %>">
<PARAM NAME="value2" VALUE="thisIsStatic">
</OBJECT>
</form>
</body>
</HTML>
Debugging
Okay, so you wire up your code, place your <Object> tag, and load up the page. Nothing. No error, nothing. You're not going to get a message (unless you dump exception strings to a label in your control). And even if you did, you start debugging aspnet_wp.exe, set some break points in your new control, and still nothing!
Here's the trick (sorry if you're not using Visual Studio): click Tools | Debug Processes, and scroll through the list of processes. Spot the IExplorer with your web page in it, and notice under the 'Types' field. See the .NET there? That's your component! Attach to that, and you will now be able to debug your .NET Applet. Pretty cool, huh!
Parameters
What! This isn't enough? You want to pass parameters to your control? You don't know how to do this? Neither did I. I never really used the Object tag much. But now I am, and passing parameters is easy.
Between your opening and closing <Object> tags place a <Param> tag. Here's an example:
<param name="publicProp" value='yadaYadaYada' />
Not to bad. How about dynamic or programmatic values? Try this:
<param name="publicProp" value='<%# myYadaValue %>' />
'myYadaValue' is a public property in your web pages code. Easy, right? Now how about values in your Applet, how do you get these? You need to create a public property. You cannot pass to a public variable, be-it string, integer, boolean, or what-not. Has to be a property. So do up your code for a property and you can now access it with Javascript.
HTH
Props to Sven Groot on Channel 9 and Ben the Developer for all the help, thanks!
Related articles
Related discussion
-
Binary Studio | software development outsourcing Ukraine
by shane124 (4 replies)
-
Research topic in software
by reachsangeethamathew (0 replies)
-
career improvement advice
by hnasr82 (0 replies)
-
Advice on studying and preparing for interviews
by caryatid (0 replies)
-
Chart insertation in a windows form...
by pdhanik (1 replies)
Related podcasts
-
More jQuery in ASP.NET
In this episode Chris Brandsma, Rick Strahl, Dave Ward, Bertrand Le Roy, and Scott Koon conclude their discussion of Microsoft's jQuery in ASP.NET announcement1.This episode of the Alt.NET Podcast is brought to you by LLBLGen Pro, the most mature O/R mapper and code generator out there.Are ...
Events coming up
-
Nov
18
15 Minutes of Fame
Dresher, United States
This is a yearly tradition. We select 10 of the favorite speakers from monthly meetings, code camps, and hands on labs. Each one does a 15 minute talk on their favorite .NET technology. This is our 10th anniversary so we plan a gala event with special prizes and refreshments.
i saw that developing the control in .net 1.1 framework is it possible... but using 2.0 i got some truble...
do you have more news?!?
Very nice and concise. Good work M!
This thread is for discussions of .NET Applets.