4

IE9 Generate blank cell or you can say Ghost Cell, with ASP.Net Repeater control. I try javascript regural expression. Render function to run reg. exp. but the page holds few update controls and generate error.

Error: sys.webforms.pagerequestmanagerservererrorexception the message received from the server could not be parsed. ScriptResource.axd

I try all the well known links for this error. Please suggest me if you really have...

Thank You

protected override void Render(HtmlTextWriter writer)
    {
      using (HtmlTextWriter htmlwriter = new HtmlTextWriter(new System.IO.StringWriter()))
      {
        base.Render(htmlwriter);
        string html = htmlwriter.InnerWriter.ToString();
         if ((ConfigurationManager.AppSettings.Get("RemoveWhitespace") + string.Empty).Equals("true", StringComparison.OrdinalIgnoreCase))
          {
            //html = Regex.Replace(html, @"(?<=[^])\t{2,}|(?<=[>])\s{2,}(?=[<])|(?<=[>])\s{2,11}(?=[<])|(?=[\n])\s{2,}", string.Empty);
            html = Regex.Replace(html, @"(?<=<td[^>]*>)(?>\s+)(?!<table)|(?<!</table>\s*)\s+(?=</td>)", string.Empty);
            html = html.Replace(";\n", ";");
          }
         writer.Write(html.Trim());
      }

another Solution is, but fail for Repeater

var expr = new RegExp('>[ \t\r\n\v\f]*<', 'g'); 
document.body.innerHTML = document.body.innerHTML.replace(expr, '><'); 
Cœur
  • 37,241
  • 25
  • 195
  • 267
user2110717
  • 269
  • 4
  • 14
  • is it possible to remove blank space between when Repeater control create new row .... I don't know how .... any one have idea... – user2110717 Mar 13 '13 at 04:26

3 Answers3

0

You can access the Repeater control directly (before it's written to the page and rendered by IE) and remove the cells based on their index.

Dave Mroz
  • 1,509
  • 2
  • 14
  • 27
  • thanks ... but these cells are not defined by me they are generated by IE9 only ... no other browser do that – user2110717 Mar 13 '13 at 04:10
  • I just re-read your post. Are you saying that IE is adding an extra cell to the table, or just an extra space between the TD tags? – Dave Mroz Mar 13 '13 at 16:56
  • Yes its IE9 Bug. Please look that,its look same.. http://stackoverflow.com/questions/5805956/internet-explorer-9-not-rendering-table-cells-properly – user2110717 Mar 14 '13 at 05:16
  • but i have simple ASPX page with repeater control using C#. NO Jquery, No Ajax – user2110717 Mar 14 '13 at 05:20
  • Whitespace between tags [inside of tables] should be ignored and no browser should be interpreting that as an extra cell. – Dave Mroz Mar 14 '13 at 13:37
  • Do you have a sample we can see? – Dave Mroz Mar 14 '13 at 13:38
  • Yes you are right no browser should interpret but IE9 create that with Table generate Dynamicly... Pls look this like my problem is same as that..http://stackoverflow.com/questions/5805956/internet-explorer-9-not-rendering-table-cells-properly – user2110717 Mar 15 '13 at 04:31
  • I have one soloution for that but its no reliable all the time.that is remove space between at Designing but what if another developer use Ctrl + E,D.... – user2110717 Mar 15 '13 at 04:34
  • It certainly shouldn't matter. I've seen hundreds of spaces and line breaks in the middle of tables and they still generate correctly. – Dave Mroz Mar 15 '13 at 10:45
  • This thread is more specific about a solution: http://stackoverflow.com/questions/7267014/ie9-table-has-random-rows-which-are-offset-at-random-columns – Dave Mroz Mar 15 '13 at 10:45
  • Thanks Dave, But I already try to do that, if I go through Regex show js error which i writen in my question. – user2110717 Mar 15 '13 at 11:50
  • Without seeing some output HTML to work with, it's tough to troubleshoot remotely. But one thing I noticed is that they did the HTML scrubbing on the client side whereas you're trying to do it on the server. Maybe give it a try using jQuery or good old fashioned JavaScript? – Dave Mroz Mar 15 '13 at 15:51
0

Need to remove spaces between "< /td >" and "< td >".

user2110717
  • 269
  • 4
  • 14
0

Found a very useful script to prevent unwanted cells in your html table while rendering in IE9 browser.

function removeWhiteSpaces()
{
   $('#myTable').html(function(i, el) {
      return el.replace(/>\s*</g, '><');
   });
}

This javascript function you should call when the page loads (i.e. onload event)

Rish
  • 1,303
  • 9
  • 22