Solved

How to use ocx in asp.net page

Posted on 2009-04-07
6
565 Views
Last Modified: 2012-05-06
I am trying to include the ocx in the webpage

please guide me
0
Comment
Question by:PBCHANDRAN
  • 3
  • 3
6 Comments
 
LVL 50

Accepted Solution

by:
Ryan Chong earned 20 total points
ID: 24084826
OCX is a client side object, you can embed it into webpage using object tag, like this:

<script language="javascript">
function CJSObject() {
      this.mAttrName = new Array();
      this.mAttrValue = new Array();
      this.mAttrNameNoValue = new Array();
      this.mParamName = new Array();
      this.mParamValue = new Array();
      this.SetAttr = function(sAttrName, sAttrValue) {
            this.mAttrName[this.mAttrName.length] = sAttrName;
            this.mAttrValue[this.mAttrValue.length] = sAttrValue;
      }
      this.SetAttrNoValue = function(sAttrName) {
            this.mAttrNameNoValue[this.mAttrNameNoValue.length] = sAttrName;
      }
      this.SetParam = function(sParamName, sParamValue) {
            this.mParamName[this.mParamName.length] = sParamName;
            this.mParamValue[this.mParamValue.length] = sParamValue;
      }
      this.GetObjectHTML = function() {
            var sRet = "";
            
            sRet += "<";
            sRet += "ob";
            sRet += "je";
            sRet += "ct";
            for (var i = 0; i < this.mAttrName.length; i++) {
                  sRet += " " + this.mAttrName[i] + "=\"" + this.mAttrValue[i] + "\"";
            }
            for (var i = 0; i < this.mAttrNameNoValue.length; i++) {
                  sRet += " " + this.mAttrNameNoValue[i];
            }
            sRet += "\">\r\n";
            for (var i = 0; i < this.mParamName.length; i++) {
                  sRet += "\t<";
                  sRet += "pa";
                  sRet += "ram";
                  sRet += " name=\"" + this.mParamName[i];
                  sRet += "\" value=\"" + this.mParamValue[i];
                  sRet += "\">\r\n";
            }
            sRet += "</";
            sRet += "obj";
            sRet += "e";
            sRet += "ct";
            sRet += ">\r\n";
            
            return sRet;                        
      }
}
</script>

then:

<script type="text/javascript">
      var gobjSLV = new CJSObject();

      gobjSLV.SetAttr("id", "yourObjID");
      gobjSLV.SetAttr("name", "objname");
      gobjSLV.SetAttr("width", "1px");
      gobjSLV.SetAttr("height", "1px");
      gobjSLV.SetAttr("classid", "clsid:E59B6131-5F73-B202-856F-146921A178BB");

      gobjSLV.SetAttr("type", "application/x-oleobject");
      gobjSLV.SetAttrNoValue("whatever");

      var sHtml = gobjSLV.GetObjectHTML();
      document.write(sHtml);
</script>

or follow link:

http://www.fpoint.com/support/whitep/ActiveX/ax1999.aspx#content
0
 

Author Comment

by:PBCHANDRAN
ID: 24085286
I want to access the function in asp.net by using ocx

and ocx will be writtern in vc++
0
 
LVL 50

Expert Comment

by:Ryan Chong
ID: 24085298
ocx is not a server side object, you only can interact with it by javascript.
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

Author Comment

by:PBCHANDRAN
ID: 24094647
I am using this Object tag in the Html page
I want to draw the lines in that object for that i have writtern ocx
The thing is  i have writtern draw function in ocx but it doesnt display in the  html page.
How to do it.
0
 
LVL 50

Expert Comment

by:Ryan Chong
ID: 24095551
>>The thing is  i have writtern draw function in ocx but it doesnt display in the  html page.

Seems that you got some problem on your object, you can try post another question so that other experts can help you debug your object scripts.
0
 

Author Comment

by:PBCHANDRAN
ID: 24105001
yes the object is working fine
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now