Avatar of Geoff Sutton
Geoff Sutton
Flag for Canada asked on

Enabling Winform Control in ASP.NET

I have been attempting to incorporate access to our AS400 server via terminal through the intranet.  http://aspnet.4guysfromrolla.com/articles/052604-1.aspx shows how to use a Winform user control in a webform page.  I have a terminal winform control which works in a winform app.  When I try following the instructions on the above site, however, I end up with a blank item on the page.  I am including the ASPX file as well as the terminal code.  I am sure that it is something simple I've missed if it could be pointed out that would be great.  
Thanks
(the winform control is an uploaded file)
//ASP.NET PAGE
<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <object id="Object1" height="600" width="600" classid="bin/TerminalControl.dll#TerminalControl.TerminalEmulator" viewastext>
            <param name="Rows" value="37" />
            <param name="Columns" value="127" />
            <param name="Hostname" value="192.168.100.212" />
        </object> 
    </form>
</body>
</html>

Open in new window

.NET ProgrammingWeb ApplicationsASP.NET

Avatar of undefined
Last Comment
Geoff Sutton

8/22/2022 - Mon
aibusinesssolutions

Did you copy the Terminalcontrol.dll file to the bin directory of the website?

Is the TerminalControl a UserControl and not a Form?
aibusinesssolutions

Oh, one other thing, are you running this in IE? I don't think it will work in any other browser.
aibusinesssolutions

Also, not sure if this is just coincidence or not, but every example I can find says to put the dll in the "root" directory of the website, not the bin folder.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Geoff Sutton

ASKER
Yes, I have tried it in the Root as well as in Bin.  I have seen a few examples of the DLL being in the BIN, the ClassID attribute being the path (relative, I believe) to the DLL.  It is a windows user control, and I have also tried the code inheriting simple from controls, same effect.  I am starting to wonder if the problem lies in hte complexity of the control, since it is a complete terminal emulator, but it does work perfectly in a winform.  I will be back at this tomorrow, and I plan on starting with a simpler control to elminate the complexity as a factor (although thinking about it I don't believe it is).
Thanks for responding, and I will double check the items you mentioned.
Geoff
aibusinesssolutions

Using VS 2008, I followed the example to the letter on that link you provided, and I can't get it to work.  I just get a placeholder box.  I can however unzip the project that is available for download, which was made in VS 2003 with .NET 1.1, and it works.  

So for a test, just recreate the project on that page, a WinForms.dll, with a treeview control on it, and display that on a normal html or aspx page.
Geoff Sutton

ASKER
I am using 2k8 also.  I will try recreating what is there then build up from that.  The Placeholder box is what I am getting also.  Thanks.  I'm glad I'm not the only one :)
 
Geoff
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Geoff Sutton

ASKER
I copied the Zip to my system and upgraded to .net 3.5.  Same problem.  Did you run yours in 2003 or did you use 2008?  I am wondering if this is something which has been phased out with the latest .Net?
Geoff
 
aibusinesssolutions

I used 2k8, but I updated it to 2.0 and it worked, I didn't try updating it to 3.5
Geoff Sutton

ASKER
Ok.  I will try it again at 2.0 see if I can get it to work.  Thanks.
 
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Geoff Sutton

ASKER
I can make the sample from the page work, but when I copy my code into that page it gives me a spaceholder, same as an img tag gives if the image can't be found.  When I use the exact same DLL in a winform it works flawlessly.  Do you know of any reasons WHY a control cannot be instantiated on a webpage?  
Thanks for the help on this,
Geoff
ASKER CERTIFIED SOLUTION
aibusinesssolutions

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
aibusinesssolutions

Particularly #5
Geoff Sutton

ASKER
This is awesome.  Thanks.
Geoff
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Geoff Sutton

ASKER
I think I found my problem:
 
" The next area is the WndProc virtual function on the Control class. This function cannot be overridden by partially trusted code because this method can potentially be used to manipulate sensitive information in the form of window messages"
I am overriding WndProc to capture keystrokes on the form.  Since this will be deployed as a web interface the code will only be partially trusted.  Hence what I want to do cannot be done.
 
Thanks for finding this for me.  I will find another workaround I suppose.
Geoff
aibusinesssolutions

Have you thought about making it into an activeX control?  
Geoff Sutton

ASKER
I have but am shying away from that.  I know nothing about developing ActiveX through .Net.  Also my plan was to ultimately include this as a control on a webportal, so I am not sure how that would work out.  What I think I will have to do is rewrite everything as a web control, or even a service, and use javascript to capture and send the keystrokes to the service, then intercept the return and post that back onto the page into a textarea or something similar.  Maybe even create a div element where I can capture keystrokes and update the data in the div according to the key pressed.  Basically this is going to require a complete rethink of the project, which is what I was really hoping to avoid :)
Thanks for the help,
Geoff
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23