Custom Pages HTML editor image update failure

Posted By tasosdr Thu 14 Nov 2013
Add to Favorites1
Author Message
tasosdr
 Posted Thu 14 Nov 2013
Supreme Being

Supreme Being - (22,131 reputation)Supreme Being - (22,131 reputation)Supreme Being - (22,131 reputation)Supreme Being - (22,131 reputation)Supreme Being - (22,131 reputation)Supreme Being - (22,131 reputation)Supreme Being - (22,131 reputation)Supreme Being - (22,131 reputation)Supreme Being - (22,131 reputation)

Group: Forum Members
Last Active: Thu 16 Jun 2022
Posts: 38, Visits: 198
Dear all,

I am trying to upload an image from using the HTML editor insode a custom page I have created. The image is only 3 Kb but in numerous tries the upload proccess always fails.
In more details either using button "Select File" or I just drag a file to the drop zone, after pressing the upload button the upload proceess starts, goes to 100% (changes from -pending to uploading - ) but then nothing happens. Stays there infinitelly. No confirm message, no post back/ refresh nothing. The image never uploads.
Do I have missed something or is it just a bug?
I am developing a project for a client of mine and it is absolutely necessary to have the ability to upload images through the CMS (HTML editor).

Thanks for your consideration.

Tasos
kentdivingdev Marked As Answer
 Posted Fri 14 Mar 2014
Supreme Being

Supreme Being - (1,316 reputation)Supreme Being - (1,316 reputation)Supreme Being - (1,316 reputation)Supreme Being - (1,316 reputation)Supreme Being - (1,316 reputation)Supreme Being - (1,316 reputation)Supreme Being - (1,316 reputation)Supreme Being - (1,316 reputation)Supreme Being - (1,316 reputation)

Group: Forum Members
Last Active: Sat 19 Jul 2014
Posts: 2, Visits: 33
Hi,

I've also come across the ajaxtoolkit issue and have a work around that gets it working, at least on the pages I have encountered. Since I've seen this a few times on the forum I thought I'd post.


Note, I use Chrome and have to drag and drop images in. I haven't looked at why the select button doesn't work yet.


The fix is based on these two articles I found:


http://ajaxcontroltoolkit.codeplex.com/workitem/27307
http://stephenwalther.com/archive/2012/05/01/ajax-control-toolkit-may-2012-release




General & Product Pages


The articles suggest that the issue is the htmleditor being in a hidden panel on page load. Since the actual editor is hidden by CSS in _HTMLEditor.ascx we are able to set the Visible = True property on the _LanguageContent.ascx page.


It is at the bottom:


<_user:HTMLEditor ID="_UC_Editor" runat="server" Visible="true" />



Next, the event handler didn't work for me in _HTMLEditor.ascx.vb so I made modifications to the function ajaxFileUpload_OnUploadComplete:




Protected Sub ajaxFileUpload_OnUploadComplete(sender As Object, e As AjaxControlToolkit.AjaxFileUploadEventArgs) Dim strFullPath As String = strFilesFolder & e.FileName htmlEditorExtender1.AjaxFileUpload.SaveAs(Server.MapPath(strFullPath)) e.PostedUrl = KartSettingsManager.GetKartConfig("general.webshopurl") + strFullPath.Replace("~/", "") End Sub






The above two changes should get it working in general.


Custom Pages


Fixing the custom page editor took a few more steps.


The extra problem here is that the editor is inside another hidden panel. I.e. even though visible is now true in _LanguageContent.ascx the panel containing this is still hidden. The article suggests a "ghost" editor which sits inside a hidden div on the page outside of any hidden panels.


Therefore, at the top of _CustomPages.ascx just under the Register tag I added this:



<div style="display:none"> <_user:LanguageContainer ID="ghost_UC_LangContainer" runat="server" /> </div>




Then you need to hook up the code behind Page_Load function. The extra challenge is to remove the required validation on the ghost editor. For this I changed the LANG_ELEM_TABLE_TYPE to PromotionStrings; just because it contains a htmleditor but doesn't require validation.


The final code change looks like this (it is at the bottom of Page_Load in _CustomPages.ascx.vb)



If GetPageID() = 0 Thenghost_UC_LangContainer.CreateLanguageStrings(LANG_ELEM_TABLE_TYPE.PromotionStrings, True)_UC_LangContainer.CreateLanguageStrings(LANG_ELEM_TABLE_TYPE.Pages, True)Else ghost_UC_LangContainer.CreateLanguageStrings(LANG_ELEM_TABLE_TYPE.PromotionStrings, False, GetPageID())_UC_LangContainer.CreateLanguageStrings(LANG_ELEM_TABLE_TYPE.Pages, False, GetPageID()) End If




That should be all for the custom pages.




I hope that is helpful, if it is not clear (I hope the code displays ok) let me know and I will try to explain it better. It feels like a bit of a hack, and there maybe a better solution, if you know it let me know.


Thanks
Craig

Fri 14 Mar 2014 by kentdivingdev

Similar Topics

Expand / Collapse

Reading This Topic

Expand / Collapse

Back To Top