Blue Theme Orange Theme Green Theme Red Theme
 
Nevron Chart
Home | Forums | Videos | Advertise | Certifications | Downloads | Blogs | Interviews | Jobs | Beginners | Training
 | Consulting  
Submit an Article Submit a Blog 
 Jump to
Skip Navigation Links
TechnologyExpand Technology
WebsiteExpand Website
Nevron Chart
Search :       Advanced Search »
Home » Windows Forms C# » Using a Windows Application on the Web

Using a Windows Application on the Web

In this article, author shows how to create a Windows Forms application and use it in an ASP.NET application for the Web.

Page Views : 25241
Downloads : 0
Rating :
 Rate it
Level : Beginner
   Print Read/Post comments Post a comment  Similar Articles  
   Email to a friend  Bookmark  Author's other articles  
 
Team Foundation Server Hosting
Become a Sponsor
DevExpress Free UI Controls
Become a Sponsor
 Tag Cloud
 Latest Jobs
More ... 
 Latest Interview Questions
More ... 

Introduction

In this article, I will show how to use a Windows Forms application in an ASP.NET Application targets for the Web.

Note: Try to use the Microsoft windows control, avoid third party control. Because we are going to use the same control on web.

Advantages:

  • Reduces the coding time and resource needed for web.
  • Bring the desktop to your web

Requirement:

Develop a windows application. For developing weather you can use windows controls are third party control that's not a matter.

Process:

1. Open  "New Project ", select Visual C# Project and select Windows Application and name the project as  'WindowsTOWeb' and click Open. See Figure 1.

Figure 1.

2. Place some controls on the Forms such as Labels, TextBoxes, and buttons. See Figure 2. I add three labels, three TextBoxes, and two button controls and change their properties accordingly.

Figure 2.

3. When you run the application, the form will look like Figure 3.

Figure 3.

4. Now we want to convert the windows application in to a usercontrol so then we can use the user control in our Web application. To convert the windows application in to a user control, we need to follow the following steps two steps:

  • Convert the

    public class Form1 : System.Windows.Forms.Form

                            TO

    public class Form1 : System.Windows.Forms.UserControl
    (See Figure 4)


    Figure 4.

  • Comment the    

    this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); of the windows.

Now your windows form application is converted to a user control

5. Now click the property of the project and change the "Output Type" from Windows Application to Class Library (See Figure 5)

Figure 5.
 
6. Before compiling the project comments the "thread". See Figure 6.

Figure 6.

Now You have successfully created a user control that contains the functionality of our Windows Forms applicatin.

7. Now we are going to add a Web Application to the solution by adding a new ASP.NET Web Application project. I call project WinToWeb. See Figure 7.

Figure 7.
 
8. Now create a strong name for your user control by using "sn.exe ", which is in the location

'C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Bin'.

The syntax for creating the string name is

C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Bin\sn -k "C:\Strongname.snk"

now the strong name has been created and it is in the c: in the name of strongname.snk

9. After creating the strong name specify the path of the strong name in "Assemblyinfo.cs " file in the [assembly: AssemblyKeyFile("c:\strongname.snk")] attribute

Now the first way of using the user control in a Web application.

10. Now by using the "regasm.exe" create and place the CLSID of your dll in the registry the exe file which is in the location "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\ ".

11. Then by using the Gacutil.exe register your WindowsToWeb .dll the the registry. Then go to the registry and search by the name "WindowsToWeb.dll" and copy the CLSID to the code behind as Specified in the figure. See Figure 8.

Figure 8.

12. Now you can see the windows control in the web form. See Figure 9.

Figure 9.

13. Run your web application. Congratulations. Your Windows Forms functionality is available on the Web now. See Figure 10.

Figure 10.

Conclusion:

This is a sample application, which I have created when I am in position to run the windows application on the Web. By using this you can run only the simple applications.

Comment Request!
Thank you for reading this post. Please post your feedback, question, or comments about this post Here.
Login to add your contents and source code to this article
 [Top] Rate this article
 
 About the author
 
Prabakar Samiyappan
MCP Certified.Working in Microsoft Technology for the Past 4 Years. http:\\sharpurdotnet.blogspot.com
Looking for C# Consulting?
C# Consulting is founded in 2002 by the founders of C# Corner. Unlike a traditional consulting company, our consultants are well-known experts in .NET and many of them are MVPs, authors, and trainers. We specialize in Microsoft .NET development and utilize Agile Development and Extreme Programming practices to provide fast pace quick turnaround results. Our software development model is a mix of Agile Development, traditional SDLC, and Waterfall models.
Click here to learn more about C# Consulting.
 
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
Discover the Top 5 .NET Memory Management Fundamentals
To write the best .NET code, you need to know exactly how the .NET framework really manages memory. Ricky Leeks presents the Top 5 fundamental facts of .NET memory management. Learn more.
Nevron Chart for .NET 2010.1 Now Available
The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
ASP.NET 4 Hosting
Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites – Click Here!
 
 Post a Feedback, Comment, or Question about this article
Subject:
Comment:
Team Foundation Server Hosting
Become a Sponsor
 Comments
please explain in detail about 10 th and 11th point by khatheeja On July 20, 2006
please explain in detail about 10 th and 11th point ie -->how to create create clsid using regasm.exe -->where can we view clsid -->how to place the clsid Also explain detaily about the 11th point step by step Thanks
Reply | Email | Modify 
Re: please explain in detail about 10 th and 11th point by Prabakar On October 30, 2006

After creating the Dll with strong name

The CLSID can be created by using regasm.exe tool

 Which is present in the C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322

 

When you pass your Dll to regasm.exe the tool will create the CLSID the CLSID

will be present in the registry of the system .Type "regedit" in run and go the registry and open HKEY_CLASSES_ROOT\CLSID\              and search with the Dll name which you have created you can easily find the clsid for the  particular Dll. Copy the CLSID and paste in the HTML as shown above and proceed the process

Reply | Email | Modify 
Re: Re: please explain in detail about 10 th and 11th point by Sairam On January 30, 2009

I got the CLSID for my dll in the registry. But I cannot copy the CLSID to my HTML.Please explain this in detail.

Thanks in advance

Reply | Email | Modify 
need help by anu On November 29, 2006

12th step: how to add reference to add user control in web application. I am getting COM reference error as follows :

A reference to 'wintowindow' could not be added.converting the type library to a .net assembly failed.

thankx in advance.

Reply | Email | Modify 
how i can pass my Dll to regasm.exe by ahmed On March 27, 2007
regasm \regfile [:"c:\doc\projects\file.dll"] give me path error please tell me correact syntex
Reply | Email | Modify 
Windows Application run on Web by Vasu On June 13, 2007
Hi, I have a huge windows Application it occupies approximately 900MB.It is a fully customized product.It doesn't have any microsoft direct toolbar controls. So now i want to covert that windows application to a Web Application.Can u please send me the details for the conversion. Thanks n Regards Vasu Rayapati...
Reply | Email | Modify 
Events by Prakash On August 22, 2007
How to use the click event of save and close button in the web application
Reply | Email | Modify 
Events by Prakash On August 22, 2007
How to use the click event of save and close button in the web application
Reply | Email | Modify 
10 and 11 points by tee On March 19, 2010
Can you please explain 10 and 11 points,they are a little confusing.
Reply | Email | Modify 
Is it possible for VB Windows application by Amit On June 18, 2010
Respected Sir,
I have one windows application which is developed in VB.Net. Is possible to convert it in the web application as this article. Please mail me on patilmilindv@gmail.com

Thanks
Milind V. Patil
9096400484
Reply | Email | Modify 
Discover the top 5 tips for understanding .NET Interop
 © 2012  contents copyright of their authors. Rest everything copyright Mindcracker. All rights reserved.