I will explain the steps to create
a web application with windows controls. I think it would more interesting if
you can do all the windows things in browser. Don’t think it will support all
the WinForm’s features in IE.
Important Notes:
·
We should create user control’s, we can replace
only the user controls in IE.
·
It will work only in IE, it doesn’t support any
other browser
·
It should installed the .NET framework in the
client machine
·
Site should be trusted site list in browser.
·
Bowser should allow downloading the files from
trusted sites.
Steps to create one sample:
1.
Create a Solution
2.
Create a Web Application. Please note we should
create the web application in IIS. If you are creating the ASP.NET Web application
then you have to change the path to web server. Go to the project properties
and change the location. If you are using Visual studio development server you
may face a lot issues like fusion binding error, modified changes don’t
reflect..
3.
Create another windows class library project and
place some windows controls here (MyFirstUserControl).
4.
Just add some code in user controls (eg.)
public partial
class MyFirstControl
: UserControl
{
public
MyFirstControl()
{
InitializeComponent();
}
private
void btnMyFirstApp_Click(object sender, EventArgs
e)
{
MessageBox.Show("Hi, This is my first windows calendar application
in browser");
}
5.
In Web application create one folder (here I
have given name “WindowsControls”)
6.
We need to place the output of wincontrols
project to the Web application’s WinControls folder, instead of adding the
reference. We can do this manually all the time; also we can use the Visual
studio feature for this. Go to the class library project properties ->Build
change the output path (..\WebApp\WinControls5\).
7.
We need to place the windows user control into the
Web page using Object tag, samples given below. Important thing need to make
sure that the classid (DLL’s physical location#namespace
of user control).
<object id="rtfcontrol"
height="472"
width="488"
classid="WinControls/WindowsControls.dll#WindowsControls.MyFirstControl"
viewastext>
</object>
8.
Rebuild the solution and run the web
application. You can see the window calendar control in IE now. J
9.
If you are using any other assembly as a
reference in the user controls that we should place in the same folder (WinControls).
Look this example here I have created DataAccessLayer and user control will
call one method from this which is GetMessage(). Our case it is not required to
copy anything; once we will add the reference it will copy the output files into
this specific folder.
10.
You never see the files in solution explorer by
default, you need go to the Show all files option and include files whatever
you need. But this is optional; we already mapped this folder in IIS.