Solved

How to use ocx in asp.net page

Posted on 2009-04-07
6
564 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 49

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 49

Expert Comment

by:Ryan Chong
ID: 24085298
ocx is not a server side object, you only can interact with it by javascript.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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 49

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
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…
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.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

863 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

23 Experts available now in Live!

Get 1:1 Help Now