recently i was working on a tool, where user makes changes on the interface and while hitting save, the template gets stored on server.. as an HTML file.. everything was well... i was able to save the file from all the major browsers (i checked on FireFox and Chrome), but when i tried to save the file from internet explorer....
it does not emit file properly.. the HTML is not properly formatted.. because of which the applications crashes...
Below is the proper format when checked from Firefox and Chrome...
<tr>
<td colspan="2" align="center">
<div class="searchDiv">
<span>Leader Board Box: </span><span class="pd2">
<textarea rows="5" cols="52" id="txtLeaderBoardAd" style="width:631px;"></textarea></span><br>
<br>
<span>Site Logo: </span><span style="padding-left: 34px">
<input type="text" size="47" id="txtLogoImage" value=""></span><span>Width: </span><span>
<input type="text" size="15" id="txtLogoImageWidth" value=""></span><span>Height: </span><span>
<input type="text" size="15" id="txtLogoImageHeight" value=""></span><br>
<br>
<span>Link Url: </span><span style="padding-left: 70px">
<input type="text" id="txtLogoLinkUrl" size="100" value=""></span><br>
<br>
</div>
</td>
</tr>
But when tried to save the same format from Internet Explorer... it emit the format like below
<TR sizset="9" sizcache="3">
<TD colSpan="2" align="middle" nodeindex="1" nodeIndex="1">
<DIV class="searchDiv">
<SPAN>Leader Board Box: </SPAN>
<SPAN class="pd2">
<TEXTAREA style="WIDTH: 631px" id="txtLeaderBoardAd" rows="5" cols="52"></TEXTAREA>
</SPAN>
<BR>
<BR>
<SPAN>Site Logo: </SPAN>
<SPAN style="PADDING-LEFT: 34px">
<INPUT id="txtLogoImage" size="47" type="text">
</SPAN>
<SPAN>Width: </SPAN>
<SPAN>
<INPUT id="txtLogoImageWidth" size="15" type="text">
</SPAN>
<SPAN>Height: </SPAN>
<SPAN>
<INPUT id="txtLogoImageHeight" size="15" type="text">
</SPAN>
<BR>
<BR>
<SPAN>Link Url: </SPAN>
<SPAN style="PADDING-LEFT: 70px">
<INPUT id="txtLogoLinkUrl" size="100" type="text">
</SPAN>
<BR>
<BR>
</DIV>
</TD>
</TR>
i dont understand... it just removes Quotes from all attributes.. and also adds extra attributes as sizset and sizcache... do i need to format for something extra for IE
Please help... i am stuck over here. *********************THIS IS HOW I AM SAVING FILE********** i am using Ajax Jquery for saving the file in html Format...
[WebMethod]
public static string WriteToHTMLFile(string data)
{
using (StreamWriter writer = new StreamWriter(HttpContext.Current.Server.MapPath("/NewsletterTemplate/HTMLPage.htm")))
{
writer.WriteLine(data);
writer.Flush();
}
return "Saved Successfully";
}
and then just calling the above function in Javascript.. like below
$.ajax({ type: "POST", url: "AjaxMethods.aspx/WriteToHTMLFile", contentType: "application/json", data: "{'data':'" + $("#dvGetHTML").html() + "'}", success: function (data) {
$("#dvGetHTML").html($("#dvGetHTML").html());
}, error: function (data) { alert("Error in Save.. Please contact your administrator !!!" + data.responseText); }
});
ahhhhhh.....
I see where your going wrong :-)
Your yanking the html straight out of the browsers DOM right? and I'm guessing that #dvGetHTML is a div?
It sounds to me like IE is in some way representing the HTML internally in a different way to the other browsers, and when you yank it it out of your div that's what your getting.
By way of an experiment, try using a plain old text area tag, you can edit in that and the formatting tends to obey good old fashioned pre tag rules.
The bonus is that anything typed in a textarea is returned verbatim as is, as though is was an input field, if you don't get the strange formatting when you do this it's likely that the problem is as anticipated.
If you prove that is your issue, then I'd use a client side editor such as "Tiny MCE" to achive what your trying to do with a div.