G
Guest
I have a simple "Hello World" UserControl I wrote with VS.NET 2003 (C#). I
added a method called "Hello" to return a string "Hello". I made a virtual
directory that allows Script (and only script), and put the DLL on it, and
then made a simple HTML file that uses an OBJECT tag to deply the DLL, where
it has script to run the UserControl as show hereafter. But it does not run,
saying the OBJECT does not have the method.
Now I've done UserControls before, and barring the trick that IIS must be
setup to run "SCRIPT ONLY", there were no problems. So what gives all of a
sudden?
C# code:
========================
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
namespace MyNameSpace
{
/// <summary>
/// Summary description for MyClass.
/// </summary>
public class MyClass : System.Windows.Forms.UserControl
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public MyClass()
{
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();
// TODO: Add any initialization after the InitComponent call
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if( components != null )
components.Dispose();
}
base.Dispose( disposing );
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
}
#endregion
public string SayHello(string csSayHelloTo)
{
System.Windows.Forms.MessageBox.Show("Hello World!!!");
return "Say hello to " + csSayHelloTo;
}
}
}
==================
HTML Code
===============
<html>
<body>
<object
id=objMyClass
classid="MyClass.dll#MyNameSpace.MyClass"
VIEWASTEXT</object>
</body>
<script language=javascript>
var objMyClass;
objMyClass = document.getElementById("objMyClass");
alert(objMyClass.SayHello("World"));
</script>
</html>
added a method called "Hello" to return a string "Hello". I made a virtual
directory that allows Script (and only script), and put the DLL on it, and
then made a simple HTML file that uses an OBJECT tag to deply the DLL, where
it has script to run the UserControl as show hereafter. But it does not run,
saying the OBJECT does not have the method.
Now I've done UserControls before, and barring the trick that IIS must be
setup to run "SCRIPT ONLY", there were no problems. So what gives all of a
sudden?
C# code:
========================
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
namespace MyNameSpace
{
/// <summary>
/// Summary description for MyClass.
/// </summary>
public class MyClass : System.Windows.Forms.UserControl
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public MyClass()
{
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();
// TODO: Add any initialization after the InitComponent call
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if( components != null )
components.Dispose();
}
base.Dispose( disposing );
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
}
#endregion
public string SayHello(string csSayHelloTo)
{
System.Windows.Forms.MessageBox.Show("Hello World!!!");
return "Say hello to " + csSayHelloTo;
}
}
}
==================
HTML Code
===============
<html>
<body>
<object
id=objMyClass
classid="MyClass.dll#MyNameSpace.MyClass"
VIEWASTEXT</object>
</body>
<script language=javascript>
var objMyClass;
objMyClass = document.getElementById("objMyClass");
alert(objMyClass.SayHello("World"));
</script>
</html>