PRB with UserControl and OBJECT/HTML/CLASSID

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>
 
G

Guest

I have new information related to this issue. The code is fine. I can run the
code from the HTML by using the Visual Studion .NET's debugger, where I
specify to run it from a URL.

So....

The problem is that IIS and/or IE are not letting me run the UserControl. To
iterate what I have done, here is a list:

- I have the virtual directory in IIS set to NOT allow Execute, but to let
it run Script.
- I can get to HTML web pages in that virtual directory.
- My IE trusts the server.
- The sample page end with ".htm".

Any ideas?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top