Solved

How to use ocx in asp.net page

Posted on 2009-04-07
6
566 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 51

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 51

Expert Comment

by:Ryan Chong
ID: 24085298
ocx is not a server side object, you only can interact with it by javascript.
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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 51

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

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.

Question has a verified solution.

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

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…

821 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