Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ActiveX Control in ASP 2

Status
Not open for further replies.

BeckD

Programmer
Apr 16, 2002
53
0
0
GB
Hi

I'm not sure if this post should be in here or in the VB forum, so apologies if this is wrong.

Basically, I want to know how to use a control created in VB on a web page. I've got as far as getting the control onto the page, but I don't know how to talk to the control once its there. Here is the code I'm using:

Code:
<form name=&quot;frm&quot;>
<OBJECT SCOPE=&quot;Session&quot; ID=&quot;rtb&quot; name=&quot;rtb&quot; classid=&quot;clsid:95A18709-BE8F-11D6-817D-0020ED174450&quot;>
</OBJECT>	
<input type=&quot;button&quot; value=&quot;Get Selected Text&quot; name=&quot;cmdSelText&quot; onclick=&quot;alert('<%= rtb.GetSelectedText %>')&quot;>
</form>

This gets me the following error on the line with rtb.getSelectedText

Microsoft VBScript runtime error '800a01a8'

Object required: ''

If I run the control within vb it works fine. How do I talk to the control from ASP?
 
Sorry, maybe I should have made myself clearer. I'm not making a dll in VB, I'm making a control - ocx file. If I use server.createobject to create the control (as you suggest with the link to a dll example), then how do I get it to display on the web page? From what I have read so far I was under the impression that I need to use the <object> tag for an ocx.
 
I am sorry, I am not familar with accessing an ocx from ASP. www.vzio.com
ASP WEB DEVELOPMENT



 
Does anyone else know how to do this? Am I trying to do something impossible?
 
Within the object tags use the param tags to set attributes of the object.

Ex.

<form name=&quot;frm&quot;>
<OBJECT SCOPE=&quot;Session&quot; ID=&quot;rtb&quot; name=&quot;rtb&quot; classid=&quot;clsid:95A18709-BE8F-11D6-817D-0020ED174450&quot;>
<param name=&quot;Caption&quot; value=&quot;Push Me&quot;>
</OBJECT>
<input type=&quot;button&quot; value=&quot;Get Selected Text&quot; name=&quot;cmdSelText&quot; onclick=&quot;alert('<%= rtb.GetSelectedText %>')&quot;>
</form>
 
Hi penauroth

Thanks, but at this stage I'm not trying to set attributes yet! I've got the control on the web page and I just want to be able to call the GetSelectedText function of the control. My code (shown above) doesn't seem to know that rtb is an object, even though I've called the control &quot;rtb&quot; in the ID and name attributes of the object tag.
 
Ok, the problem is that you are declaring the object to be client side (ie, not declaring it server side). I am not sure that declaring it server side would help this, but it may. Your ASP probably doesn't even recognize the object name because the object isn't being instantiated until the entire page has hit the client machine, which is after all of the ASP has been processed and executed. Setting the object to runat=&quot;Server&quot; may solve the problem, I am not sure if ASP will be able to talk to it or not. What you could do instead is try this:
Code:
<form name=&quot;frm&quot;>
<OBJECT SCOPE=&quot;Session&quot; ID=&quot;rtb&quot; name=&quot;rtb&quot; classid=&quot;clsid:95A18709-BE8F-11D6-817D-0020ED174450&quot;>
</OBJECT>    
<input type=&quot;button&quot; value=&quot;Get Selected Text&quot; name=&quot;cmdSelText&quot; onclick=&quot;alert('rtb.GetSelectedText')&quot;>
</form>
Since the object is client side, this is a client-side call to the function. You may need to add document. to it to referencing issues.
Also, be aware that right now this object will only load if it is installed and registered on the clients machine.
-Tarwn ------------ My Little Dictionary ---------
Reverse Engineering - The expensive solution to not paying for proper documentation
 
Hi Tarwn

It works!!!!!! Hooray!!

Thanks for your help. I understand your logic though with asp not seeing it as it's not loaded when the asp is run. I hadn't thought it through properly.

BTW - I did know that it won't work unless the object is installed on the clients machine - but seeing as I'm only doing this for administration pages it won't be a problem.

Just in case anyone is interested, here's the code that WORKS!!

Code:
<form name=&quot;frm&quot;>
<OBJECT SCOPE=&quot;Session&quot; ID=&quot;rtb&quot; name=&quot;rtb&quot; classid=&quot;clsid:95A18709-BE8F-11D6-817D-0020ED174450&quot;></OBJECT>	
<input type=&quot;button&quot; value=&quot;Get Selected Text&quot; name=&quot;cmdSelText&quot; onclick=&quot;alert(document.frm.rtb.getSelectedText())&quot;>
</form>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top