Passing params to an embedded control in IE
-
I am hosting a .NET control inside of IE. Syntax: However, I want my .aspx page to be able to pass params to the PrintConfig.dll, is this possible ? If so, could you point me to a reference or documentation ? Thanks.
R.Bischoff .NET, Kommst du mit?
-
I am hosting a .NET control inside of IE. Syntax: However, I want my .aspx page to be able to pass params to the PrintConfig.dll, is this possible ? If so, could you point me to a reference or documentation ? Thanks.
R.Bischoff .NET, Kommst du mit?
First, your
classid
attribute should not include "http:". Use a relative path or an absolute path. Only include "http://" plus the host name if you want to use a control from another site (in which case that site needs to be configured in the Url evidence for the code access security group that must be created - all covered in my article I linked the other day. On your class interface, declare a property of typeobject
orIWebBrowser2
(requires that you reference the shdocvw.dll native COM server, which creates an interop assembly (default is typicallyInterop.SHDocVw.dll
) that must be in the same directory (or if you read the documentation about the assembly binding configuration settings - you can figure out other places to put it) as the PrintConfig.dll. Make sure you implement this property in your user control. Then, in your .aspx page for theonload
event of your OBJECT (to make sure it's loaded first, otherwise an error will occur), set that property to thewindow
object of the web browser. You must use a dispatch interface or the scripting engine cannot access the object model. My article I linked also covers this, as well as why auto-generated class interfaces should not be used (declare them explicitly and implement them as the first interface in your class declaration).Microsoft MVP, Visual C# My Articles
-
First, your
classid
attribute should not include "http:". Use a relative path or an absolute path. Only include "http://" plus the host name if you want to use a control from another site (in which case that site needs to be configured in the Url evidence for the code access security group that must be created - all covered in my article I linked the other day. On your class interface, declare a property of typeobject
orIWebBrowser2
(requires that you reference the shdocvw.dll native COM server, which creates an interop assembly (default is typicallyInterop.SHDocVw.dll
) that must be in the same directory (or if you read the documentation about the assembly binding configuration settings - you can figure out other places to put it) as the PrintConfig.dll. Make sure you implement this property in your user control. Then, in your .aspx page for theonload
event of your OBJECT (to make sure it's loaded first, otherwise an error will occur), set that property to thewindow
object of the web browser. You must use a dispatch interface or the scripting engine cannot access the object model. My article I linked also covers this, as well as why auto-generated class interfaces should not be used (declare them explicitly and implement them as the first interface in your class declaration).Microsoft MVP, Visual C# My Articles
Sorry about that Heath, I just skimmed your article, I should have read more thoroughly. Filling the gap of the .aspx page (server) and the embedded control (local machine) with the web browser interface makes perfect sense. I'll give it a go! Thanks again for the tips.
R.Bischoff .NET, Kommst du mit?
-
First, your
classid
attribute should not include "http:". Use a relative path or an absolute path. Only include "http://" plus the host name if you want to use a control from another site (in which case that site needs to be configured in the Url evidence for the code access security group that must be created - all covered in my article I linked the other day. On your class interface, declare a property of typeobject
orIWebBrowser2
(requires that you reference the shdocvw.dll native COM server, which creates an interop assembly (default is typicallyInterop.SHDocVw.dll
) that must be in the same directory (or if you read the documentation about the assembly binding configuration settings - you can figure out other places to put it) as the PrintConfig.dll. Make sure you implement this property in your user control. Then, in your .aspx page for theonload
event of your OBJECT (to make sure it's loaded first, otherwise an error will occur), set that property to thewindow
object of the web browser. You must use a dispatch interface or the scripting engine cannot access the object model. My article I linked also covers this, as well as why auto-generated class interfaces should not be used (declare them explicitly and implement them as the first interface in your class declaration).Microsoft MVP, Visual C# My Articles
Heath Stewart wrote: Then, in your .aspx page for the onload event of your OBJECT (to make sure it's loaded first, otherwise an error will occur), set that property to the window object of the web browser. Does OBJECT has an
onload
event ? During the step of setting the property, say Prop1 to the window object, what does this syntax look like ? p.s. Is it possible for my .aspx to read values from the embedded c# control ? thanks again.R.Bischoff
-
Heath Stewart wrote: Then, in your .aspx page for the onload event of your OBJECT (to make sure it's loaded first, otherwise an error will occur), set that property to the window object of the web browser. Does OBJECT has an
onload
event ? During the step of setting the property, say Prop1 to the window object, what does this syntax look like ? p.s. Is it possible for my .aspx to read values from the embedded c# control ? thanks again.R.Bischoff
No, but you could use
onreadystatechanged
:<object id="myControl" clsid="MyAssembly.dll#MyNamespace.MyControl"
onreadystatechanged="setProperties();">
</object>
<script language="javascript">
function setProperties()
{
if (myControl.readyState == "complete")
myControl.Prop1 = "something";
}Don't forget, though, that you can use the
<param>
tags inside the<object>
element to set public properties on the control as well.Microsoft MVP, Visual C# My Articles