Setting the ContentURL Property at Run Time
In C1Window you can include external content in a dialog window. This means that you can have the content of another Web page in your project appear in your website or event the content of a Web site outside of your project. Pointing to external content is simple using the ContentURL property.
To change the dialog window's ContentURL property at run time, call the set_contentURL method on the client side to get and set the content of the dialog window. To set the ContentURL in design time or in code instead, see Showing External Content in the Content Area.
Complete the following steps to set the ContentURL property on the client side:
1. Navigate to the Visual Studio Toolbox, and double-click the C1Window icon to add the C1Window control to your page.
2. Click on the Source tab to switch to the .aspx code. Note that the code in the body of the page looks similar to the following:
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<cc1:C1Window ID="C1Window1" runat="server">
</cc1:C1Window>
</div>
</form>
</body>
3. To customize the location and size of the dialog window, add text to the <cc1:C1Window> tag so it looks like the following:
<cc1:C1Window ID="C1Window1" runat="server" Height="250px" Width="375px" ShowOnLoad="True" StartPosition="Manual" X="10" Y="80">
This sets the ShowOnLoad property to True, the Width property to 375px, the Height property to 225px, the StartPosition property to Manual, the X property to 10, and the Y property to 80.
4. Enter the following code after the </cc1:C1Window> tag to create a text box and a button to get and set the content of the dialog window:
<br /><input id="TxtUrl" type="text" value="http://www.componentone.com" />
<input id="button1" type="button" value="Set ContentUrl" onclick="dialog.setUrl(document.getElementById('TxtUrl').value)" />
5. Click on the Design tab to switch to design view. Notice that the size of the dialog window reflects the changes you just made.
6. Click the control's smart tag () to open the C1Window Tasks menu.
7. In the C1Window Tasks menu, click on the VisuaStyle drop-down arrow and select Office2007Black.
8. Double-click the page to switch to the Code view and create the Page_Load event handler.
9. Add the following code to the Page_Load event handler to initialize the C1Window control:
Form.Controls.Add(New LiteralControl(String.Format("<script type=text/javascript>setTimeout('window.dialog = {0}.control;',500)</script>", C1Window1.ClientID)))
• C#
Form.Controls.Add(new LiteralControl(String.Format("<script type=text/javascript>setTimeout('window.dialog = {0}.control;',500)</script>", C1Window1.ClientID)));
This topic illustrates the following:
1. Run the project and click the Set ContentURL button.
The Web page will appear as follows:
2. Enter a new URL in the text box and click the Set ContentURL button again.
The Web site you have just entered will be loaded into the dialog window.
|