You can see the result on http://www.extensions-hair.com]http://www.extensions-hair.com
Just replace Render method in NopCommerceStore/Controls/BaseNopPage.cs
protected override void Render(HtmlTextWriter writer)
{
if (showExecutionTimer)
{
executionTimer.Start();
}
////Modif NICO
// Obtain the HTML rendered by the instance.
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
base.Render(hw);
try
{
string html = sw.ToString();
// Hose the writers we don't need anymore.
hw.Close();
sw.Close();
string viewstate = null, /*postback = null,*/ onSubmit = null;
// Find the viewstate.
int startViewstate = html.IndexOf(@"<input type=""hidden"" name=""__VIEWSTATE""");
if (startViewstate > -1)
{
// Find the first preceding div tab
int startViewstateDiv = html.LastIndexOf(@"<div>", startViewstate);
// If we find it, then move it.
if (startViewstateDiv > -1)
{
// Find the first folowing /div
int endViewstateDiv = html.IndexOf("</div>", startViewstateDiv) + 6;
// Strip out the viewstate.
viewstate = html.Substring(startViewstateDiv, endViewstateDiv - startViewstateDiv);
html = html.Remove(startViewstateDiv, endViewstateDiv - startViewstateDiv);
}
}
// Find the OnSubmit script.
int startOnSubmit = html.IndexOf(@"function WebForm_OnSubmit()");
if (startOnSubmit > -1)
{
// Find the first preceding script tag
int startOnSubmitScript = html.LastIndexOf(@"<script type=""text/javascript"">", startOnSubmit);
// If we find it, then move it.
if (startOnSubmitScript > -1)
{
// Find the first folowing /script
int endOnSubmitScript = html.IndexOf("</script>", startOnSubmitScript) + 9;
// Strip out the doOnSubmit.
onSubmit = html.Substring(startOnSubmitScript, endOnSubmitScript - startOnSubmitScript);
html = html.Remove(startOnSubmitScript, endOnSubmitScript - startOnSubmitScript);
}
}
// Find the end of the form and insert it there, since we can't put it any lower in the response stream.
int formend = html.LastIndexOf(("</form>"));
if (viewstate != null) html = html.Insert(formend, viewstate);
if (onSubmit != null) html = html.Insert(formend, onSubmit);
// Send the results back into the writer provided.
writer.Write(html);
}
catch (Exception ex)
{
base.Render(writer);
LogManager.InsertLog(LogTypeEnum.CommonError, "Moving ViewState and doPostBack to the end of the form!", ex);
}
if (showExecutionTimer)
{
executionTimer.Stop();
RenderExecutionTimerValue(writer);
}
}
I gess it will be a problem if someone submits this page before page is completly loaded, then I a also moved the submit script. But this is not perfect!
Does anyone have ideas to improve this script?
(sorry for my english... hope you understand :))