473,767 Members | 2,077 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using com control in asp.net

I am trying to include a legacy com control (controlname.oc x) 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 1154
DocAccolade wrote:
I am trying to include a legacy com control (controlname.oc x) 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.H tmlControls.Htm lGenericControl (double-check that namespace).

Example:

Protected WithEvents objMyObjectID As
System.Web.UI.H tmlControls.Htm lGenericControl

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.inter face.
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.oc x) 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.H tmlControls.Htm lGenericControl (double-check that namespace).

Example:

Protected WithEvents objMyObjectID As
System.Web.UI.H tmlControls.Htm lGenericControl

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
3076
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 to appear in the report is Yes, No, or Maybe. What do I need to do to change what appears in the report/what term do I need to search out in Google? Thank you Colin
8
2744
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. But I have 2 quesitons: 1. How can I REMOVE a selection from the Destination List box - and keep the others there? My first code removes ALL from the Source list; this code does nothing. 2. How can I now USE the data - I have to...
9
3975
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 will not set the value of the control and will leave the checked status of the checkbox to false when a user selects a new date. this works fine when using the control on a win2k machine but if we use it on a win XP box and call
0
3482
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 that I can set the comm state however when I try and read from the port using ReadFile method I cannot, I've tried to change the DCB object flag types but this does not make a difference as I still cannot read from the port. I have pasted my code...
5
3161
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 the code variable that are supposed to be linked to the contained controls. It runs fines when everything is contained in a single web form project. What do I need to do to make it work from a class library?
3
1504
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. /// <summary> /// Render this control to the output parameter specified.
15
4778
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 button will verify the information that has been entered and updates the data base if the data is correct. Update will throw an exception if the data is not validate based on some given rules. I also have a custom error handling page to show the...
4
6904
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 (select something in a dialog from the dialog editor or a class from the class list and hit F4). I used Spy++, which revealed that the window class of the property grid control used by Visual Studio is "WindowsForms10.Window.8.app.0.378734a". So,...
53
4754
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, and .Net2005 code. I'm developing in vb.net 2005. This test sub just reads an input text file, writing out records to another text file, eliminating records that have a '99' in them (it is similar to a CSV file). Some of my concerns are:
6
1884
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 pressing a button or changing text in a textbox). It gets set up and on the user control on my web page I can see the event from intellisense. So it seems to be set up, but I am trying to get an easy example of how I would now use this event. ...
0
9571
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10013
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9960
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8838
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7383
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6655
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3930
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 we have to send another system
2
3533
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2807
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.