This is a migrated thread and some comments may be shown as answers.
Trying to remove unneeded characters does not work with AjaxManager
3 Answers 80 Views
This is a migrated thread and some comments may be shown as answers.
Jason Maronge
Top achievements
Rank 1
Jason Maronge asked on 25 Apr 2007, 03:37 PM
I have the Render method on my base page overridden to remove whitespaces and return lines, etc. 

        protected override void Render(HtmlTextWriter writer)  
        {  
            StringWriter stringWriter = new StringWriter();  
            HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter);  
            base.Render(htmlWriter);  
            string html = stringWriter.ToString();  
            html = html.Replace("\t"""); // tabs  
            html = html.Replace("  "" "); // double spaces  
            html = html.Replace(" />""/>"); // space before end of tags  
            html = html.Replace(">\r"">"); // space before end of tags  
            html = html.Replace(">\n"">"); // space before end of tags  
            writer.Write(html);  
        } 

Everything works fine with the regular ajax manager but the new one seems to have a problem with me doing this. (Sys.WebForms.PageRequestManagerParseErrorException: The message recieved from the server could not be parsed. etc...)  I assume it is due to how MS formats the return string to the browser.  Am I out of luck on getting this to work? 

Thanks... Jason

3 Answers, 1 is accepted

Sort by
0
Todd Anglin
Top achievements
Rank 2
answered on 25 Apr 2007, 03:53 PM
Jason-

Without doing a lot of research, one way to determine which replacement is causing problems would be to comment out all of your replacements and slowly add them back until the Ajax problems occur. That will at least make it clear which of your replacements is really causing the problem (if not all of them).

Thanks~
Todd
0
Jason Maronge
Top achievements
Rank 1
answered on 25 Apr 2007, 05:15 PM
Todd,

    I had tried that and it turns out that the only Replace I can keep in is the Replace(">\n"">");.  I do not think it is that big of a deal since it was not saving that much space to start with.  I am using compression on the site so it might be overkill to remove the characters anyway.  I was just wondering if anyone knew what the issue was. 

Thanks... Jason
0
Mike
Top achievements
Rank 1
answered on 25 Apr 2007, 05:22 PM
It's probably something internal to MS AJAX, e.g. the way it Diff's the page on partial rendering to figure out what needs to be sent to client, etc...

But indeed, string replacing on large Html chunks may prove slower than just sending it through the pipe (and let Http compression take care of the rest).

Still, it's a curious fact that the rad Ajax engine (the original one) does not have this problem...
Tags
Ajax
Asked by
Jason Maronge
Top achievements
Rank 1
Answers by
Todd Anglin
Top achievements
Rank 2
Jason Maronge
Top achievements
Rank 1
Mike
Top achievements
Rank 1
Share this question
or