473,466 Members | 1,367 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Using com control in asp.net

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

Nov 19 '05 #1
2 1134
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
Nov 19 '05 #2
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

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Colin McGuire | last post by:
Hi, I have an report in Microsoft Access and it displays everything in the table. One column called "DECISION" in the table has either 1,2, or 3 in it. On my report it displays 1, 2, or 3. I want...
8
by: sara | last post by:
I am learning Access and programming. I wanted to have the user select the departments for an ad from the list of all departments. Found code (that I could understand) on this site, and it works....
9
by: Guy | last post by:
I have extended the datetimepicker control to incorporate a ReadOnly property. I have used the new keyword to implement my own version of the value property, so that if readonly == true then it...
0
by: Jim dunn | last post by:
HI I am having problems with C# with regards to its compatibility with win32 API methods, I am trying to read from a windows CE comm port using C# and imported methods from coredll.dll, it seems...
5
by: Marcel Gelijk | last post by:
Hi, I am trying to create a User Control that is located in a seperate class library. The User Control contains a textbox and a button. The page generates an exception when it tries to access...
3
by: msnews.microsoft.com | last post by:
Hello All, I am trying to write Web Controls and in most of the samples I came across, I am seeing the following function where a HTML string is written to create HTML Controls. ///...
15
by: Nathan | last post by:
I have an aspx page with a data grid, some textboxes, and an update button. This page also has one html input element with type=file (not inside the data grid and runat=server). The update...
4
by: Dave Calkins | last post by:
I have a native Win32 C++ app built with Visual Studio 2005. I'd like to make use of a property grid control in this app. For an example of this, in Visual Studio, see the properties control...
53
by: Hexman | last post by:
Hello All, I'd like your comments on the code below. The sub does exactly what I want it to do but I don't feel that it is solid as all. It seems like I'm using some VB6 code, .Net2003 code,...
6
by: tshad | last post by:
I was looking at a page that showed how to set up a custom event and it seems to work ok. But I am not sure how I would use it. How would I subscribe to it. There is actual action (such as...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.