Topbar
Topbar
Sign in
|
Join
|
Client Center
Home
Products
Client Center
Contact
Purchase
Support forums
»
Products
»
Cute Editor for .NET
»
Re: Custom Drop Down List : Insert Selected Item in Editor.
Re: Custom Drop Down List : Insert Selected Item in Editor.
08-10-2009, 6:06 AM
Kenneth
Joined on 02-13-2008
Posts 3,886
Re: Custom Drop Down List : Insert Selected Item in Editor.
Reply
Quote
HI
ashi.avinashvyas
,
Try this code
<%@ Page Language=
"C#"
Debug=
"true"
%>
<%@ Register Assembly=
"CuteEditor"
Namespace=
"CuteEditor"
TagPrefix=
"CE"
%>
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
>
<html xmlns=
"http://www.w3.org/1999/xhtml"
>
<head runat=
"server"
>
<title>Untitled Page</title>
<script runat=
"server"
>
protected
override
void
OnLoad(EventArgs e)
{
CuteEditor.ToolControl tc = Editor1.ToolControls[
"insertcustombutonhere"
];
if
(tc !=
null
)
{
System.Web.UI.WebControls.DropDownList ddl1 =
new
System.Web.UI.WebControls.DropDownList();
ddl1.Items.Add(
new
ListItem(
"-- Select Field --"
));
ddl1.Items.Add(
new
ListItem(
"hello"
));
ddl1.Items.Add(
new
ListItem(
"show text"
));
for
(
int
i = 0; i < ddl1.Items.Count; i++)
{
ddl1.Items[i].Attributes[
"onclick"
] =
"showOptionValue(this)"
;
}
ddl1.Attributes[
"onclick"
] =
"simOptionClick()"
;
tc.Control.Controls.Add(ddl1);
}
base
.OnLoad(e);
}
</script>
</head>
<body>
<form id=
"form1"
runat=
"server"
>
<CE:Editor ID=
"Editor1"
runat=
"server"
TemplateItemList=
"[Bold]/[insertcustombutonhere]/[Italic]"
>
</CE:Editor>
</form>
</body>
</html>
<script type=
"text/javascript"
>
function simOptionClick()
{
var evt=window.
event
;
var selectObj=evt?evt.srcElement:
null
;
if
(evt && selectObj && evt.offsetY && evt.button!=2
&& (evt.offsetY > selectObj.offsetHeight || evt.offsetY<0 ) )
{
setTimeout(function(){
var option=selectObj.options[selectObj.selectedIndex];
showOptionValue(option)
}, 60);
}
}
function showOptionValue(opt)
{
var editor1 = document.getElementById(
'<% = Editor1.ClientID%>'
);
editor1.PasteHTML(opt.text);
}
</script>
Regards,
Ken
View Complete Thread