473,385 Members | 1,958 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,385 software developers and data experts.

Calling a local .NET UserControl from a local HTML page

I am hosting .Net UserControls in HTML pages with Object Tags. These
UserControls are clients of remotable objects that run on the same machine.
The remote objects execute callbacks via sponsor objects. The UserControl
client creates and passes these sponsor objects to the remote objects.

I am able to launch .Net UserControls and their dependent .Net components in
HTML pages using the Object tag. I had to do the following to get it to work.

1. Run IIS
2. Build all assemblies with strong names.
3. Remove all copies of existing assemblies from the GAC's download directory.
4. Put the HTML page in the root of my machine's web site (I'm running XP
Pro).
The HTML page uses an Object tag whose classid is
"http:UserControl.dll#Class.Name".
5. Put the UserControl DLL in the same directory as the HTML page.
6. Create a bin directory under the root and copy the dependent DLLs there.
7. Set the Local Security Policy of the Local Machine to Full Trust on the
Intranet Zone to allow access to a remote server that is running on the same
machine.

Questions:
1. I have found that I cannot launch the UserControl unless IIS is running
and all of the above are as specified. Is there a way to launch a .Net
UserControl in an HTML page without running IIS?
2. Do I have to specify the classid as "http:UserControl.dll#Class.Name" or
can I use
something like "file:filespec\UserControl.dll#Class.Name"?
3. Is there a way to make the UserControl version-specific, like we did with
CAB files, so that they will reload and install automatically when an update
is available?
Jul 21 '05 #1
3 3147
The <object> tag's CODEBASE will NOT take a file:// url for security reasons
(so that you can not use already installed ActiveX controls with malicious
purposes). So yes, the page needs to come from a web server.
Is there a way to make the UserControl version-specific, like we did with
CAB files


No (as far as I know). This is a bummer. What I did to prevent the control
from being downloaded every time is I built a wrapper control, very small in
size (and very simple in API) that has one property that tells the version
of the assembly to load, this wrapper uses LoadAssembly using this version
information and therefore downloads the assembly only when it is needed.

One important thing I discovered is that for some reason IE takes a LONG
time to load the page the first time explorer hits it if the control is very
"complex" (has a lot of properties and events), this is not noticeable when
working locally but it has a big impact (about 30 secs in my case) when
hitting a page in a remote site, this is why the wrapper control has to be
very "simple".

Since JScript works through Dispatch only, your wrapper object can expose a
property of type Object that returns the original control so that you can
script it.

I hope this helps.

--
Francisco Padron
www.chartfx.com
Jul 21 '05 #2
Thanks Francisco.
Do you know if there's a way to reference the object's classid or codebase
to a web url, but still have the html page just loaded as a file into IE?
Our testing indicates that the html page needs to be called via http (i.e.
http://localhost/page.html), otherwise the .NET object will not load
properly, even if the component's classid is referenced to a url.

"Francisco Padron" wrote:
The <object> tag's CODEBASE will NOT take a file:// url for security reasons
(so that you can not use already installed ActiveX controls with malicious
purposes). So yes, the page needs to come from a web server.
Is there a way to make the UserControl version-specific, like we did with
CAB files


No (as far as I know). This is a bummer. What I did to prevent the control
from being downloaded every time is I built a wrapper control, very small in
size (and very simple in API) that has one property that tells the version
of the assembly to load, this wrapper uses LoadAssembly using this version
information and therefore downloads the assembly only when it is needed.

One important thing I discovered is that for some reason IE takes a LONG
time to load the page the first time explorer hits it if the control is very
"complex" (has a lot of properties and events), this is not noticeable when
working locally but it has a big impact (about 30 secs in my case) when
hitting a page in a remote site, this is why the wrapper control has to be
very "simple".

Since JScript works through Dispatch only, your wrapper object can expose a
property of type Object that returns the original control so that you can
script it.

I hope this helps.

--
Francisco Padron
www.chartfx.com

Jul 21 '05 #3

That's because the CODEBASE for the control has to be the SAME as the page,
in other words, if you have a page in:

www.foo.com

Your control can not come from another site, say www.foo2.com, it has to
come from the same. Similarly, if your page is coming from C:\somepath, then
your control can not be downloaded from any site.

I believe this is for security reasons, maybe some MSFT person wants to
comment on this.

--
Francisco Padron
www.chartfx.com
Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Mark Friedman | last post by:
I can't seem to figure out how to get a reference to a UserControl in the code-behind for the page that contains the control. All the examples I've seen show how to pass property values from the...
2
by: bill yeager | last post by:
When trying to run my web project, I get the following error: Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the...
2
by: Sascha | last post by:
Hi there, I searched carefully through the web before finally deciding to post this message, because I could not find a solution for my problem. Hopefully someone will have a hint or explanation...
0
by: N. Demos | last post by:
Hello, I have a custom usercontrol, of which I have two instances of in my aspx page. Both the usercontrol and page have codebehind. In the page codebehind, I want a member variable for each...
3
by: Jeff Turner | last post by:
I want to install a few .NET assemblies on the local machine and then embed a UserControl in IE via COM -- in other words, I will wrap the assembly in COM and call it form IE so that my UserControl...
1
by: Will Gillen | last post by:
I know this has probably been asked before, but I can't seem to find a solid answer in any of the archives. First, before my question, please forgive my limited knowledge of the event lifecycle...
5
by: Dave McCracken | last post by:
I am hosting .Net UserControls in HTML pages with Object Tags. These UserControls are clients of remotable objects that run on the same machine. The remote objects execute callbacks via sponsor...
12
by: Joe | last post by:
Hello All: Do I have to use the LoadControl method of the Page to load a UserControl? I have a class which contains three methods (one public and two private). The class acts as a control...
0
by: oliver | last post by:
QUESTION: How to access an object embedded in a UserControl through Javascript file? Another way to ask this question: How to execute script from a UserControl, accessing other objects in that...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.