Hi JJoyce,
Example:
|
How to create a custom button(client side) which displays a dialog?( C# | VB )
This example demonstrates how easy it can be to add your own client side buttons to the CuteEditor by creating a Cross Browser Modal Dialog Box. |
Source (you can find the source code in the download example too )
Example download:
Location CuteEditor_for_NET6.zip\Framework 2.0\HowTo\AddDialogs\cs
aspx page
- <%@ Register TagPrefix="CE" Namespace="CuteEditor" Assembly="CuteEditor" %>
- <%@ Page language="c#"%>
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
- <script language="JavaScript" type="text/javascript" >
- function ShowMyDialog(button)
- {
-
- var editor=CuteEditor_GetEditor(button);
-
-
- var newwin=editor.ShowDialog(null,"My_Custom_Text.html?_rand="+new Date().getTime()
- ,editor,"dialogWidth:400px;dialogHeight:240px");
- }
- </script>
-
- <html>
- <head>
- <title>ASP and ASP.NET WYSIWYG Editor - How to create a custom button which displays a dialog?</title>
- <link rel="stylesheet" href="../../example.css" type="text/css" />
- </head>
- <body >
- <form runat="server" ID="Form1">
- <h2>How to create a custom button which displays a dialog?</h2> <hr>
- <br>
- In this example, first we get the location of Italic button. Then we add a custom dialog after it.
- <br><br>
- <CE:Editor id="Editor1" ThemeType="OfficeXP" AutoConfigure="Minimal" EditorWysiwygModeCss="example.css" runat="server" ></CE:Editor><br />
-
-
- </form>
- </body>
- </html>
- <script runat="server">
- private void Page_Load(object sender, System.EventArgs e)
- {
-
-
-
- int pos=Editor1.ToolControls.IndexOf("Italic")+1;
-
-
- WebControl ctrl=Editor1.CreateCommandButton("MyButton","text.gif","Insert My Custom Text");
-
- ctrl.Attributes["onclick"]="ShowMyDialog(this)";
-
-
- Editor1.InsertToolControl(pos,"MyButton",ctrl);
- }
- </script>
Dialog page
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
- <html>
- <head>
- <title>Insert Text</title>
- </head>
- <body bgcolor="#d4d0c8">
- <div align="center" style="padding:8px">
- <textarea rows="6" cols="40" id="ta" NAME="ta">Type content here</textarea>
- <br>
- <button onclick="button_click()" ID="Button1">Insert It</button>
- <button onclick="window.top.close();" ID="Button2">Close</button>
- </div>
- </body>
- <script>
- function button_click()
- {
- var editor=Window_GetDialogArguments(window);
- var ta=document.getElementById("ta");
- editor.PasteHTML(ta.value);
- }
- function Window_GetDialogArguments(win)
- {
- var top=win.top;
- if(top.dialogArguments)
- return top.dialogArguments;
- var opener=top.opener;
- if(opener==null)
- return top.document._dialog_arguments;
- return opener.document._dialog_arguments;
- }
- </script>
- </html>
Regards,
Ken