Creating a Modeless Dialog Window in Code
This topic details how to create a modeless dialog window in code. For more information about modeless dialog windows see the topic, Modeless Dialog Windows.
Complete the following steps to create a modeless C1Window in code:
1. Add a reference to the C1.Web.UI.Controls.2.dll file in your project.
2. Navigate to the Toolbox and double-click the PlaceHolder icon to add the control to your page.
3. Switch to Source view and add the following JavaScript just above the opening <html> tag to get and show the modeless dialog window:
<script type="text/javascript">
var form_dialog;
function openWindow(dialog)
{
form_dialog = dialog.control;
form_dialog.show();
}
</script>
4. Return to Design View and double-click the page to switch to Code view and create the Page_Load event.
5. Add the following at the top of the page to import the C1.Web.UI.Controls.C1Window namespace:
Imports C1.Web.UI.Controls.C1Window
• C#
using C1.Web.UI.Controls.C1Window;
6. In the Page_Load event add the following code to create the content, style, and general appearance for the modeless dialog window:
'Create a hyperlink and add it to the page's controls.
Dim hyprlnk As HyperLink = New HyperLink
hyprlnk.Text = "Show Modeless Dialog Window"
Page.Controls.Add(hyprlnk)
' Create a new C1Window control and add it to the page's controls.
Dim dialog As C1Window = New C1Window
PlaceHolder1.Controls.Add(dialog)
' Set the dialog window's caption bar content.
dialog.Text = " Information"
dialog.CaptionButtons.MaximizeButton.Visible = False
dialog.CaptionButtons.MinimizeButton.Visible = False
dialog.StatusVisible = False
' Set the dialog window's initial position.
dialog.StartPosition = C1WindowPosition.Manual
dialog.X = 50
dialog.Y = 50
' Set the dialog window's initial size.
dialog.Width = Unit.Pixel(250)
dialog.Height = Unit.Pixel(150)
' Set the open dialog window handler.
hyprlnk.NavigateUrl = String.Format("javascript:openWindow({0});", dialog.ClientID))
• C#
//Create a hyperlink and add it to the page's controls.
HyperLink hyprlnk = new HyperLink();
hyprlnk.Text = "Show Modeless Dialog Window";
Page.Controls.Add(hyprlnk);
// Create a new C1Window control and add it to the page's controls.
C1Window dialog = new C1Window();
PlaceHolder1.Controls.Add(dialog);
// Set the dialog window's caption bar content.
dialog.Text = " Information";
dialog.CaptionButtons.MaximizeButton.Visible = false;
dialog.CaptionButtons.MinimizeButton.Visible = false;
dialog.StatusVisible = false;
// Set dialog window's initial position.
dialog.StartPosition = C1WindowPosition.Manual;
dialog.X = 50;
dialog.Y = 50;
// Set dialog window's initial size.
dialog.Width = Unit.Pixel(250);
dialog.Height = Unit.Pixel(150);
// Set the open dialog window handler.
hyprlnk.NavigateUrl = String.Format("javascript:openWindow({0});", dialog.ClientID);
This topic illustrates the following:
Run the program and click on the Show Modeless Dialog Window link; the dialog window will appear similar to the following:
|