Hi Nilendra,
Please find the below piece of code from my application.
Ajax Call:
else if ($("#iFrameHtmlImage")[0] != null) {
$.ajax({
type: "POST",
url: "Default.aspx/ReplaceHTMLFile",
data: JSON.stringify({ "content": str, "name": $("#iFrameHtmlImage")[0].src }),
contentType: "application/json; charset=utf-8",
dataType: "json",
processData: false,
success: function (msg) {
refreshMainHtml($("#iFrameHtmlImage")[0].src);
document.getElementById('iFrameHtmlImage').contentDocument.location.reload(true);
lblText.Set("Text", undefined);
},
error: function (msg, status) {
if (status === "error") {
}
}
});
}
Web method:
[WebMethod]
public static string ReplaceHTMLFile(string content, string name)
{
try
{
string fileTempLocation = ConfigurationManager.AppSettings["TemporaryHtmlFilePath"];
string htmlHedder = "<!DOCTYPE html> \n <html lang='en'> \n";
StringBuilder sbContent = new StringBuilder(content);
sbContent = sbContent.Replace("<html>", htmlHedder);
var uri = new Uri(name);
var path = Path.GetFileName(uri.AbsolutePath);
StreamWriter tw = new StreamWriter(fileTempLocation + path, false, Encoding.Default, 0x640000);
tw.WriteLine(sbContent.ToString());
tw.Close();
}
catch (Exception ex)
{
ExceptionPolicy.HandleException(ex, "DesignS");
HttpContext.Current.Session["DesignSErrMsg"] = ex.Message;
}
return "";
}
Request you to please provide the solution.