When I insert an image the WebHtmlEditor puts the full path into the markup. This is an issue because I am developing on my PC, it will then move to a development server for testing, and then it will move again to the production server - all of which have different base URLs but the same folder structure. How do I tell the editor not to paste in the full path - only the relative path from the site root?
I am using 7.1.20071.40 - would a newer version work better?
Here is my current code:
edExplanation.UploadedFilesDirectory = "~/UploadedFiles";
Here is the code, partially given to me by Infragistics support, that creates a client side script for the AfterAction event. Using this you can determine if the action was an image insert and adjust the rendered html accordingly to remove the base of the url from the string to make the image path relative.
string afterActionEventScript = @"function edAfterAction(oEditor, actID, oEvent, p4, p5, p6, p7, p8){if (actID == 'InsertImage') {var txt = oEditor.getText();var homeURL = this.location.protocol + '//' + this.location.host + '" + Request.ApplicationPath + @"/';txt = txt.replace(homeURL, '');oEditor.setText(txt);} }";if (!Page.ClientScript.IsClientScriptBlockRegistered("edAfterAction")) {Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "edAfterAction", afterActionEventScript, true); } edExplanation.ClientSideEvents.AfterAction = "edAfterAction";
string afterActionEventScript = @"function edAfterAction(oEditor, actID, oEvent, p4, p5, p6, p7, p8){
}";
{
}
edExplanation.ClientSideEvents.AfterAction = "edAfterAction";
You can also handle other events, such as paste. NOTE: the "Paste" action only occurs when someone clicks the right-click menu or one of the standard menu buttons on the WebHtmlEditor - NOT on "ctrl-v". ie: (JavaScript, inside edAfterAction)
if (actID == 'Paste') { alert('you just pasted something'); }
I don't completely understand what this is doing.
var homeURL = this.location.protocol + '//' + this.location.host + '" + Request.ApplicationPath + @"/';
I have a content management system. I want the images to be uploaded to say c:/inetpub/wwwroow/app1 but I am running from c:/inetpub/wwwroow/app2. I don't really care if it hardcodes the path of the image instead of a relative path, but right now if course it's putting the directory of where I got the image from on MY computer. What is the best way to make it UPLOAD the pic to the location on the server and also change it from MY path to that path.
Oh, I just figured out a way to filter out the HTML on paste (from the ctrl-v combination keyboard event, from the menu button and from the right-click menu). I posted that solution here: https://ko.infragistics.com/community/forums/f/retired-products-and-controls/15702/lost-cell-format-after-post-back#15702