Solved

How Do You Create a Popup Window in C#?

Posted on 2011-09-13
11
382 Views
Last Modified: 2012-05-12
How do you create a popup window in C#?

Thanks,

Dan
0
Comment
Question by:danielolorenz
11 Comments
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 36531028
WinForms or WebForms?

Can you elaborate more on what you consider a "popup" window to be and/or contain?
0
 
LVL 44

Assisted Solution

by:AndyAinscow
AndyAinscow earned 90 total points
ID: 36531051
The following would display a custom windows form (called myform) as a modeless window.
myform.Show();

Is that what you wanted ?
0
 

Author Comment

by:danielolorenz
ID: 36531107
a myform would be perfect.

How do you import?  It does not recognize it.
0
 

Author Comment

by:danielolorenz
ID: 36531109
I could also use WinForms if you show me how to use it.
0
 

Author Comment

by:danielolorenz
ID: 36531132
This is a small popup for a web application
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 44

Assisted Solution

by:AndyAinscow
AndyAinscow earned 90 total points
ID: 36531143
OK, I'll repeat my comment with a small change

The following would display a custom windows form (called YourCustomFormNameGoesHere) as a modeless window.
YourCustomFormNameGoesHere.Show();

Is that what you wanted ?



YourCustomFormClassNameGoesHere YourCustomFormNameGoesHere = new YourCustomFormClassNameGoesHere();
YourCustomFormNameGoesHere.Show();

Open in new window

0
 

Author Comment

by:danielolorenz
ID: 36531169
Yes, this is what I want.  It is for a web application.  How do you code this from scratch?
0
 

Author Comment

by:danielolorenz
ID: 36531170
I am getting an error
0
 
LVL 9

Assisted Solution

by:BlueYonder
BlueYonder earned 195 total points
ID: 36532126
Ajax may be your best option.  Download ajax from http://www.asp.net/ajaxlibrary/download.ashx.  Follow the tutorial for the modal popup.  http://www.asp.net/ajaxlibrary/act_ModalPopup.ashx.  Add <%@ Register Assembly="AjaxControlToolKit" Namespace="AjaxControlToolkit" TagPrefix="asp" %> above all content tags, but below the page.  Add a script manager to the page, it is in the ajax tools and add it into the maincontent part of the page.  it looks like    
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" EnablePartialRendering="true">
    </asp:ToolkitScriptManager>
0
 
LVL 12

Accepted Solution

by:
starlite551 earned 215 total points
ID: 36532464
OK I have the perfect solution for you.. All you need to do is follow a few simple steps and you get windows forms Message Box Control or Form class itself accessible in the Web Application. So here are the steps :
1. Go to Solution Explorer Right Click on The Project and Click on Add References.
2. An Add Reference Dialog Box Will Appear.
3. In The .NET Components Section Browse Down Till You See System.Windows.Forms Namespace Reference.Select that by clicking the checkbox next to it and click on OK.
4. After you have done so. Go to the Code Section of your .aspx.cs Page. At the top of the code file in the namespace references using statements list add the following line :
 
using System.Windows.Forms;

Open in new window

5. Now you can call classes that reside within this namespace directly in your Web Application.
6. For Example you can then use the following code in a button click event :
protected void Button1_Click(Object sender,EventArgs e)
{
      MessageBox.Show("You Clicked "+Button1.ClientId.ToString()); 
}

Open in new window

0
 

Author Closing Comment

by:danielolorenz
ID: 36536529
That was great help.  Your solutions were very good.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now