spencet:
In the File Selector example, we would like to trigger an ASP.NET function after the Upload and Insert buttons are pressed and the CE window is closed but having trouble grabbing the CE.Unload event. Anyone have an example of how to do this or a better way to accomplish our goal?
Thanks
Hi spencet,
Try the example below. You can add your logic in method "button1.Click". it will fire after you inser a picture.
-
<%@ Register TagPrefix="CE" Namespace="CuteEditor" Assembly="CuteEditor" %>
-
-
<%@ Page Language="C#" %>
-
-
<script runat="server">
-
-
protected void button1_Click(object sender, EventArgs e)
-
{
-
-
ClientScript.RegisterClientScriptBlock(this.GetType(), "showMessage", "<script>alert('you insert a photo')</" + "script>");
-
}
-
</script>
-
-
<html>
-
<head>
-
<title>ASP and ASP.NET WYSIWYG Editor - Use CuteEditor as an image selector</title>
-
</head>
-
<body>
-
<form runat="server">
-
<table border="0" cellpadding="0" cellspacing="0">
-
<tr>
-
<td width="10" nowrap>
-
</td>
-
<td width="20" nowrap>
-
</td>
-
<td valign="top" width="760">
-
<b>Use CuteEditor as an image selector</b>
-
<hr>
-
This example demonstrates how to use CuteEditor as an image selector.
-
<br>
-
<br>
-
<asp:TextBox ID="imageFld" Width="300" runat="server" />
-
<input type="button" value="Change Image" onclick="callInsertImage()" id="Change"
-
runat="server" name="Change">
-
<div>
-
<CE:Editor ID="Editor1" runat="server" Width="1" Height="1" AutoConfigure="None"
-
ShowHtmlMode="False" ShowPreviewMode="False" EnableContextMenu="false" ShowGroupMenuImage="False"
-
ShowBottomBar="False" BackColor="White" BorderColor="White">
-
</CE:Editor>
-
<br>
-
</div>
-
</td>
-
<tr>
-
</tr>
-
</table>
-
<asp:Button ID="button1" runat="server" Text="test" OnClick="button1_Click" Style="visibility: hidden" />
-
</form>
-
-
<script language="javascript">
-
-
function callInsertImage()
-
{
-
-
var editor1 = document.getElementById('<%=Editor1.ClientID%>');
-
editor1.FocusDocument();
-
var editdoc = editor1.GetDocument();
-
editor1.ExecCommand('new');
-
editor1.ExecCommand('ImageGalleryByBrowsing');
-
InputURL();
-
}
-
-
function InputURL()
-
{
-
var editor1 = document.getElementById('<%=Editor1.ClientID%>');
-
var editdoc = editor1.GetDocument();
-
var imgs = editdoc.images;
-
if(imgs.length>0)
-
{ document.getElementById("imageFld").value = imgs[imgs.length-1].src;
-
document.getElementById("<%=button1.ClientID%>").click();
-
editor1.ExecCommand('new');
-
document.getElementById("imageFld").focus();
-
}
-
else
-
{
-
setTimeout(InputURL,500);
-
}
-
-
}
-
</script>
-
-
</body>
-
</html>
Regards,
ken