Access Windows Forms Control in IE from code behind

E

Eric

If I have a windows form control declared in my aspx page:

<OBJECT id="wcControl" classid="http:MyControl.dll#MyControls.wcControl"
height="100%" width="100%" VIEWASTEXT>
</OBJECT>

Can I not access it through code behind? Declaring a variable of the
controls type does not initialize it and if I specify a runat=server I get a
runtime error stating a valid guid is required for classid.
 
B

bruce barker

if you put at runat=server on an object tag, then the object is created on
the server side not the client, same as the script tag. if you want to
control the object tags attributes from the code behind, use a placeholder
and add a generic to it, or us the <%= %> syntax:

<OBJECT id="wcControl" classid="http:MyControl.dll#MyControls.wcControl"
height="100%" width="100%" VIEWASTEXT>
<parameter name="p1" value="<% =myObjectP1Value%>">
</OBJECT>


-- bruce (sqlwork.com)
 
S

Steven Cheng[MSFT]

Thanks a lot for Bruce's informative suggestions.

Hi Eric,

As for the question "control the IE host winform control" in severside
codebehind code. Here are my suggestions:

The IE host winform control( embeded in web page) are rich client features
in dotnet. In fact, the winform control's assembly will be downloaded to
clientside and then run in client side's dotnet runtim(clr). So there is no
serverside class instance acutally. That's why we use clientside script to
manipulate the rich client winform control embeded in IE. However, if you
just want to do some operations on the certain control's attributes, you
may try Bruce's suggestion that use the embeded <% %> server side script
block in the <object... >.

In addition, here are some tech articles on hosting winform user controls
in IE:

#Host Secure, Lightweight Client-Side Controls in Microsoft Internet
Explorer
http://msdn.microsoft.com/msdnmag/issues/02/01/UserCtrl/default.aspx

#Developing Compelling User Controls that Target Forms in the .NET Framework
http://msdn.microsoft.com/msdnmag/issues/02/04/WinForms/default.aspx

#Controles WinForm (UserControls) en IE
http://www.microsoft.com/spanish/msdn/comunidad/mtj.net/voices/art94.asp

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top