C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » ASP.NET »

windows control in web Application


Posted Date: 04 Dec 2008      Posted By: Venkat      Member Level: Silver     Points: 1   Responses: 2



hi friends,
In my application i need to add windows control into web form.So that,i add window.form reference and name space and get the corresponding control.But if i add that control in my page like form1.Controls.Add(cntl_name) then it shows an error.
How to rectify this problem?If anyone know the answer plz help me..
Thanks in advance.
regards,
Venkat





Responses

Author: srikanth ravipati    05 Dec 2008Member Level: SilverRating: 2 out of 52 out of 5     Points: 6

How to Place .NET Windows Forms Control To ASP.NET Web Form
Hosting Windows Controls on a web form is one of the interesting features of Visual Studio. This can be very useful actually, because we all know that creating Windows applications is sometime more flexible than Web applications. In Windows applications you have more control and you have access to a lot of .NET Framework classes that you don't find in Web applications.




Clearly Drawing in a windows form is easier, accessing data and the way data is displayed are much different, etc...

So to go about this, we will first create a simple Windows application, and I'll show you later on in this tutorial how I will embed it within our page. We will use Windows Control Library instead of a new Windows application.
Open up visual studio, press File-->New-->Project.
Choose "Windows Control Library" and leave the other default settings.


In the control library, insert a label into your form and save your changes.
Make sure you Debug the project because we will need the dll file produced to be used within our web application.


Now close the solution and create a new website.
To do so, press File-->New-->Website. Give your site a name. Mine is web_project.


Now you will need your dll file produced in the previous project, copied to where your asp.net website is.
Usually, you should locate your dll file in "bin" folder of your project. Copy that dll and place it in the root of the website.


Now go back to your website in visual studio, and get the HTML code of the Default.aspx page.
Add the following code within the "form" tag:

<!-- Code Starts Here -->
<object id="myName" classid="http:WindowsControlLibrary1.dll#WindowsControlLibrary1.UserControl1"
height="70" width="350" VIEWASTEXT/>
<!-- Code Ends Here -->

Save your changes and Run the site. An alert will be prompted to you asking wether to trust the dll file or not.


Click Run to allow the dll to be launched in Internet Explorer.
This will load the dll file to your web page. It should look something like image below:



Author: Murali    05 Dec 2008Member Level: GoldRating: 2 out of 52 out of 5     Points: 6

http://www.beansoftware.com/ASP.NET-Tutorials/Place-Windows-Control-To-Web-Form.aspx

Clearly Drawing in a windows form is easier, accessing data and the way data is displayed are much different, etc...

So to go about this, we will first create a simple Windows application, and I'll show you later on in this tutorial how I will embed it within our page. We will use Windows Control Library instead of a new Windows application.
Open up visual studio, press File-->New-->Project.
Choose "Windows Control Library" and leave the other default settings.


In the control library, insert a label into your form and save your changes.
Make sure you Debug the project because we will need the dll file produced to be used within our web application.


Now close the solution and create a new website.
To do so, press File-->New-->Website. Give your site a name. Mine is web_project.


Now you will need your dll file produced in the previous project, copied to where your asp.net website is.
Usually, you should locate your dll file in "bin" folder of your project. Copy that dll and place it in the root of the website.


Now go back to your website in visual studio, and get the HTML code of the Default.aspx page.
Add the following code within the "form" tag:

<!-- Code Starts Here -->
<object id="myName" classid="http:WindowsControlLibrary1.dll#WindowsControlLibrary1.UserControl1"
height="70" width="350" VIEWASTEXT/>
<!-- Code Ends Here -->

Save your changes and Run the site. An alert will be prompted to you asking wether to trust the dll file or not.


Click Run to allow the dll to be launched in Internet Explorer.
This will load the dll file to your web page. It should look something like image below:



Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : Fill dropdownlist
Previous : How to hold the data from the output parameters of store procedure?and view it in grid?
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use