473,386 Members | 1,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Retrieving Data from ActiveX Control found on ASPX Page

Frinavale
9,735 Expert Mod 8TB
I can't believe I'm asking this.
I've looked everywhere for an answer to what seems to be a simple question...

How do you retrieve data from an ActiveX control found on an ASPX page?

I've never used ActiveX controls in a web page and normally I never would...but the web application I'm currently developing requires one.

I've created the control and have added it to my asp page like so:
Expand|Select|Wrap|Line Numbers
  1.   <object id="myActiveXCtrl" classid="clsid:xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" ></object>
I'm just not sure how to retrieve the ActiveX control on the server.
(Well really all I need is the data within the ActiveX control)

Thanks a lot!

-Frinny
Oct 1 '07 #1
13 3516
Plater
7,872 Expert 4TB
Well I know how to talk to it from the webpage itself, you could use that to pipeline it back to the server:

I got this from an example just yesterday, if you instanciate the object with the object tags, you can use the public properties as you like.
(Since my object was created in .net I had to make an "interface" with the public properties available to it)
Expand|Select|Wrap|Line Numbers
  1. <body>
  2.         <hr>  
  3.         <font face=arial size=1>
  4.             <OBJECT id="myControl1" name="myControl1" classid="myax.dll#myax.myControl" width="500px" height="500px">
  5.             </OBJECT>
  6.         </font>  
  7.         <form name="frm" id="frm">
  8.             <input type="text" name="txt" value="enter text here">
  9.             <input type=button value="Click me" onClick="doScript();return false;">
  10.         </form>
  11.         <hr>
  12.     </body>  
  13.     <script language="javascript">
  14.         function doScript()
  15.         {
  16.             myControl1.UserText = frm.txt.value;
  17.         }
  18.     </script>
  19.  
Oct 2 '07 #2
Frinavale
9,735 Expert Mod 8TB
Well I know how to talk to it from the webpage itself, you could use that to pipeline it back to the server:

I got this from an example just yesterday, if you instanciate the object with the object tags, you can use the public properties as you like.
(Since my object was created in .net I had to make an "interface" with the public properties available to it)
Expand|Select|Wrap|Line Numbers
  1. <body>
  2.         <hr>  
  3.         <font face=arial size=1>
  4.             <OBJECT id="myControl1" name="myControl1" classid="myax.dll#myax.myControl" width="500px" height="500px">
  5.             </OBJECT>
  6.         </font>  
  7.         <form name="frm" id="frm">
  8.             <input type="text" name="txt" value="enter text here">
  9.             <input type=button value="Click me" onClick="doScript();return false;">
  10.         </form>
  11.         <hr>
  12.     </body>  
  13.     <script language="javascript">
  14.         function doScript()
  15.         {
  16.             myControl1.UserText = frm.txt.value;
  17.         }
  18.     </script>
  19.  
Ok, I'd seen this but didn't think it was appropriate for my application.
I think I can adapt it to suit my needs.

Thanks a lot Plater!

-Frinny
Oct 2 '07 #3
Frinavale
9,735 Expert Mod 8TB
Well I know how to talk to it from the webpage itself, you could use that to pipeline it back to the server:

I got this from an example just yesterday, if you instanciate the object with the object tags, you can use the public properties as you like.
(Since my object was created in .net I had to make an "interface" with the public properties available to it
...
I didn't want to put a layer of JavaScript in there and so I was resistant to that recommendation before.

My ActiveX control (developed in VB6) works fine.
However my .NET version of the control does not work.
I'm assuming it's because of some sort of security issue that is preventing it from executing on the client's machine.

So my next question, naturally, is do you know how to establish a trust between the .NET "ActiveX" control and the client's Operating System?

Thanks again!

-Frinny
Oct 2 '07 #4
Plater
7,872 Expert 4TB
I was going to suggest that you can probably import and instanciate the activeX object in your backend code jsut the way you would an asp:label or whatnot. (set runat="server" ?)

Yeah there's some mondo trust stuff in there. I couldn't figure it out yesterday so I gave up on it. I was just goofin around.
There are like securityflags that you can request/assert and then your webpage/server needs to be in the "trusted sites" zone on the browser or something.
Don't forget to flush out your global cache every time you change your .net activex object!
Oct 2 '07 #5
Frinavale
9,735 Expert Mod 8TB
I was going to suggest that you can probably import and instanciate the activeX object in your backend code jsut the way you would an asp:label or whatnot. (set runat="server" ?)
I tried that already but apparently the control will not work with the runat="server" attribute set. Seems a bit crazy to me but that's the way it works.


Yeah there's some mondo trust stuff in there. I couldn't figure it out yesterday so I gave up on it. I was just goofin around.
There are like securityflags that you can request/assert and then your webpage/server needs to be in the "trusted sites" zone on the browser or something.
I'll give this a try again...I've tried it in the past without any luck.
I just really don't want to use a true ActiveX because it lacks the security that a .NET control has.

Don't forget to flush out your global cache every time you change your .net activex object!
Yeah, testing this stuff does seem to really fill up the global cache with junk quickly.

Thanks again!

-Frinny
Oct 2 '07 #6
Frinavale
9,735 Expert Mod 8TB
Right now I'm using a very simple control.
It has a label that has some text in it and a text box that has some default text in it (which is then reset by the control's Page Load event)

The whole .NET ActiveX is as follows:
Expand|Select|Wrap|Line Numbers
  1. Public Interface IDotNetActiveX
  2.     ReadOnly Property MyString() As String
  3. End Interface
  4.  
  5.  
  6. Public Class MyControl
  7.     Implements IDotNetActiveX
  8.  
  9.     Private Sub MyControl_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  10.   Txt_MyTextBox.Text = "This is some text loaded in the page Load event...."
  11.     End Sub
  12.  
  13.     Public ReadOnly Property MyString() As String Implements IDotNetActiveX.MyString
  14.         Get
  15.             Return "This is the String"
  16.         End Get
  17.     End Property
  18. End Class
  19.  
It works fine when I debug it on it's own.
But when I place it into the aspx page...
As Such:
Expand|Select|Wrap|Line Numbers
  1. <object id="testDotNetActiveX" name="testDotNetActiveX" classid="~/Bin/DotNetActiveXControl.dll#DotNetActiveXControl.MyControl" height="300px" width="300px"></object>
The TextBox in the control but the label and the text that should be displayed in the TextBox is not displayed.

This gives me the impression that the control is never loaded.

I tried demanding permissions but all to no avail.
(Maybe I shouldn't have gotten rid of my permission demanding code....but...I'm still looking for thoughts on your problem)

There seems to be no information on how to debug these sorts of controls.....
Have you had any luck with your .NET control?



-Frinny
Oct 2 '07 #7
Plater
7,872 Expert 4TB
ActiveX controls (of the .NET nature) only load when coming from a webserver (IIS).
Maybe running them the way you have keeps them from loading?

I always have to "click" my activex controls for them to run.

my .net activeX to go along with the html code from earlier:
Expand|Select|Wrap|Line Numbers
  1. namespace myax
  2. {
  3.     public interface AxMyControl
  4.     {
  5.         String UserText { set; get; }
  6.     }
  7.     public partial class myControl : UserControl, AxMyControl
  8.     {
  9.       private String mStr_UserText="";
  10.  
  11.       public String UserText
  12.       {
  13.             get { return mStr_UserText; }
  14.             set
  15.             {
  16.                 mStr_UserText = value;
  17.                 //Update the text box control value also.
  18.                 txtUserText.Text = value;
  19.             }
  20.       } 
  21.  
  22.       public myControl()
  23.       {
  24.             InitializeComponent();    
  25.       }       
  26.     }//end of class
  27. }//end of namespace
  28.  
Oct 2 '07 #8
Frinavale
9,735 Expert Mod 8TB
I'm still stuck.
I've been clearing the global cache using the gacutil tool (gacutil /cdl).
I've added a Sub that simply writes a string in the TextBox and I call that sub in my JavaScript code...

But nothing ever happens....I even tried turning off my anti virus...and setting all of the ActiveX settings in my browser to prompt for any activity....


Through this I get the impression that the control is loaded...because I'm being prompted to let the control load...but it just doesn't do anything. (Well it appears that way).

My .NET ActiveX looks like this now:
Expand|Select|Wrap|Line Numbers
  1.  
  2. Public Interface IDotNetActiveX
  3.     ReadOnly Property MyString() As String
  4.     Sub LoadMe()
  5. End Interface
  6.  
  7.  
  8. Public Class MyControl
  9.     Implements IDotNetActiveX
  10.  
  11.  
  12.     Private Sub MyControl_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  13.         Txt_MyTextBox.Text = "This is some text loaded in the page Load event...."
  14.     End Sub
  15.  
  16.     Public ReadOnly Property MyString() As String Implements IDotNetActiveX.MyString
  17.         Get
  18.  
  19.             Return "This is a String"
  20.         End Get
  21.     End Property
  22.     Public Sub LoadMe() Implements IDotNetActiveX.LoadMe
  23.         Txt_MyTextBox.Text = "This is some text loaded in the page Load event...."
  24.     End Sub
  25.     Public Sub New()
  26.  
  27.         ' This call is required by the Windows Form Designer.
  28.         InitializeComponent()
  29.  
  30.         ' Add any initialization after the InitializeComponent() call.
  31.  
  32.     End Sub
  33.  
  34. End Class
And in the ASP.NET portion I call the .NET ActiveX.

Expand|Select|Wrap|Line Numbers
  1. <object id="testDotNetActiveX" name="testDotNetActiveX" classid="~/Bin/DotNetActiveXControl.dll#DotNetActiveXControl.MyControl" height="300px" width="300px" onclick="doSomething();return false;"></object>
  2.  
Expand|Select|Wrap|Line Numbers
  1.  <script type="text/javascript">
  2.                 function doSomething()
  3.                  {  
  4.                     aspnetForm.testDotNetActiveX.LoadMe();
  5.                     /*aspnetForm is the name of the Form that my control is located in*/                   
  6.                  }
  7.        </script>
  8.  
I've also tried moving this to an IIS Server and setting the lesser restrictions on the "Bin" directory (where the resource has been included).

There has to be something I'm over looking!
Oct 2 '07 #9
Plater
7,872 Expert 4TB
Well I did notice that your class there doesn't have ang UI associated with it?
Mine is:
public partial class myControl : UserControl, AxMyControl

So it hase the UI associated with being a UserControl, you don't inhereit from that so maybe that is why nothing is showing up?
Oct 2 '07 #10
Frinavale
9,735 Expert Mod 8TB
Well I did notice that your class there doesn't have ang UI associated with it?
Mine is:
public partial class myControl : UserControl, AxMyControl

So it hase the UI associated with being a UserControl, you don't inhereit from that so maybe that is why nothing is showing up?
Ok that's kind of strange...I never noticed that before.

I didn't develop my control based on a Web User Control...I developed it based on a User Control (windows desktop application). Perhaps the partial class implementation is specific to Web User Controls?

For instance, where in a desktop UI would you set the CodeFile attribute that you would set in the Page directive of a Web User Control in order to specify what file the implementation is stored in????


Did you use a Web User Control? Or a User Control?
Oct 2 '07 #11
Frinavale
9,735 Expert Mod 8TB
So it hase the UI associated with being a UserControl, you don't inhereit from that so maybe that is why nothing is showing up?
Something is showing up...the TextBox shows up. But none of the text shows up in the control...the text is set in the Load event...and also in the LoadMe method.
Oct 2 '07 #12
Plater
7,872 Expert 4TB
I was using regular user control, which is why i asked because yours is just "class"?
Oct 2 '07 #13
Frinavale
9,735 Expert Mod 8TB
I was using regular user control, which is why i asked because yours is just "class"?
I just created a new user control to double check that I hadn't deleted something by accident.

The code for User Controls is just a simple Public Class...apparently....
Oct 2 '07 #14

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Allan Cammish | last post by:
I have seen some examples of client-side code inside an ActiveX control posting data back to the server in ASP. I have tried the code and it works well. However, I need to see how this is done...
3
by: Lyle Fairfield | last post by:
In a recent thread there has been discussion about Data Access Pages. It has been suggested that they are not permitted on many or most secure sites. Perhaps, that it is so, although I know of no...
8
by: Alex | last post by:
Hello, I am trying to access some windows components from a web based application and I am having trouble find my way. The only solution seems to be to creat an ActiveX control to access the...
1
by: Mehr H | last post by:
I have been working on this for several days and am still have had no success in achieving this. Pleae help. It seems that documentation for this is very limited. I have looked in several books and...
3
by: EJ1003 | last post by:
Hello I would like to create Activex Control uisng C# and use it in ASP.Net webform. User Control is not solving my requirement so I am going for Activex Control. Please guide me on this, how...
5
by: fniles | last post by:
We created an ActiveX control and marked it as safe for scripting using Implements IObjectSafety. We then created a CAB file and signed it using Verisign. We also created a license file (LPK file)...
7
by: Sirplaya | last post by:
I am retrieving images that I stored in SQL Server on my web pages in C#. I have no problem with the images displaying, however, I am trying to wrap the image with an <A HREF ..." and each time I...
5
by: Randy Smith | last post by:
Hi ALL, I wonder if anyone has been using n-tier to bind to a GridView control by using the ObjectDataSource. This is our first OOP web application, and we have no tables. Right now we are...
1
by: kret | last post by:
Hi, this is my first post so first of all I would like to say hello :) Now getting to my problem. In my job I have to create an ActiveX control in .NET 1.1 that can be lunched from IE....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...

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.