Craig,
Thanks for the suggestions, however, I tried each with no success. The
object is a type of video interface control, written by a third party, which
has many properties and methods associated with it. After adding it, the
namespace is and the interface are both available when I declare the object
variable which I have declared as :: dim objvar as new namespace.interface.
I did try declaring as a generic control but that would not associated any
properties or methods of the control.
The control shows as a generic object with its clsid. in the html view but
adding a runat="server" tag throws an error which the error handler
associates with a bad clsid when it parses the line.
The problem is really associated with any legacy com object which is placed
on a form. I realize that .net has 2 methods of handling legacy com and
should create the necessary unmanaged code interface from the com to .net
when the object is placed. I even took some vb6 objects 'datepicker' and
tried to drop them on the form but could not recognize their properties or
methods in the code behind.
As I said, I am just a novice at asp.net and feel like I am just missing
something obvious. Thanks again for your suggestions.
"Craig Deelsnyder" wrote:
DocAccolade wrote: I am trying to include a legacy com control (controlname.ocx) in an asp.net
application using vs 2003. I have added the control to the user control tool
box, then dragged it to the form. However, when i try to reference it in
code, it does not seem to exist. I declared the object variable and the ide
reports the class members. The intellisense then recognizes the child members
of the object variable and provides them in a drop down, however when
attempting to execute the code, it fails with - Object reference not set to
an instance of an object.
I am a long time vb programmer trying my best to make the switch to .net and
after trying to solve this problem for the last 10 hours or so hope that
someone might have an answer or at least point me in the right direction.
Thanks
Not sure if this'll work, but try adding the variable yourself to the
code-behind. Meaning look at one of the existing variables, where it's
declared, copy the line, change the variable name to the ID you gave the
object tag in the codefront, and change the type to
System.Web.UI.HtmlControls.HtmlGenericControl (double-check that namespace).
Example:
Protected WithEvents objMyObjectID As
System.Web.UI.HtmlControls.HtmlGenericControl
Note this is what you have to do when trying to alter the <title> tag,
etc. VS.NET will not automatically add the declaration to the
code-behind for these 'outside the FORM tag' elements (e.g. the tags in
the HEAD section of the HTML document), although you can access them as
well...
Oh, also make sure you added a runat="server" attribute to the object
tag in the HTML....
--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET