Reputation: 121
I'm trying to use the ajaxcontrol tool kit htmleditor. below is the code that i found online
<asp:TextBox ID="txtInstruction" runat="server" Wrap="true" Width="600px" Height="300px" TextMode="MultiLine" />
<ajaxToolkit:HtmlEditorExtender ID="MyHtmlEditorExtender" runat="server" TargetControlID="txtInstruction" DisplaySourceTab="true"
OnImageUploadComplete="MyHtmlEditorExtender_ImageUploadComplete" >
<Toolbar>
<ajaxToolkit:Undo />
<ajaxToolkit:Redo />
<ajaxToolkit:Bold />
<ajaxToolkit:Italic />
<ajaxToolkit:Underline />
<ajaxToolkit:StrikeThrough />
<ajaxToolkit:Subscript />
<ajaxToolkit:Superscript />
<ajaxToolkit:JustifyLeft />
<ajaxToolkit:JustifyCenter />
<ajaxToolkit:JustifyRight />
<ajaxToolkit:JustifyFull />
<ajaxToolkit:InsertOrderedList />
<ajaxToolkit:InsertUnorderedList />
<ajaxToolkit:CreateLink />
<ajaxToolkit:UnLink />
<ajaxToolkit:RemoveFormat />
<ajaxToolkit:SelectAll />
<ajaxToolkit:UnSelect />
<ajaxToolkit:Delete />
<ajaxToolkit:Cut />
<ajaxToolkit:Copy />
<ajaxToolkit:Paste />
<ajaxToolkit:BackgroundColorSelector />
<ajaxToolkit:ForeColorSelector />
<ajaxToolkit:FontNameSelector />
<ajaxToolkit:FontSizeSelector />
<ajaxToolkit:Indent />
<ajaxToolkit:Outdent />
<ajaxToolkit:InsertHorizontalRule />
<ajaxToolkit:HorizontalSeparator />
<ajaxToolkit:InsertImage />
</Toolbar>
</ajaxToolkit:HtmlEditorExtender>
here is the bode behind
protected void MyHtmlEditorExtender_ImageUploadComplete(object sender, AjaxFileUploadEventArgs e)
{
// Generate file path
string filePath = "~/tmpImages/" + e.FileName;
// Save uploaded file to the file system
var ajaxFileUpload = (AjaxFileUpload)sender;
ajaxFileUpload.SaveAs(MapPath(filePath));
// Update client with saved image path
e.PostedUrl = Page.ResolveUrl(filePath);
}
the error message that i am keep getting is "Unable to cast object of type 'UploadRequestProcessor' to type 'AjaxControlToolkit.AjaxFileUpload'." everytime i click on upload button.
I'm getting the example from AJAX Html Editor Extender upload image appearing blank so i'm not sure what i'm missing. if i take this line of code var ajaxFileUpload = (AjaxFileUpload)sender; out, it will let me save the upload image into the folder but the image would be blank in the editor. Any help is really appreciated. thank you so much for your help
Upvotes: 0
Views: 85
Reputation: 720
This issue is fixed and queued to the next release.
You can download the latest build from here with the fix.
Upvotes: 1