tags:

views:

76

answers:

3

I'm using a control in my asp.net web page that I don't have the source code, this control renders some undesirable BR(new line) tags in HTML which they are breaknig my layout. I would like to know if there is a way I can take control of render process without breaking control behaviour (it is a very complex ajax powered one) or do something client side.

I tried to use CSS to solve that, but without sucess... indeed, it works in firefox but doesnt in IE6:

#my-div-place-holder br
{
  position: absolute;/*hack: Supress BR tags*/
}
+1  A: 

How about using an HttpModule to filter the rendered HTML? I like the CSS idea though, too bad it does work in IE.

David Peters
+1  A: 

You have two different options for injecting your own rendering for a control:

  1. Subclass the server control and override the Render method.
  2. Use ASP.Net Control Adapters

If you opt to subclass, you might have access to base class methods (if they exist) which perform different aspects of the rendering so you don't have to implement the entire rendering logic yourself.

If you prefer not to delve into server-side rendering, you could accomplish the same thing with javascript.

Ken Browning
@Ken Browning, thanks for you fast reply. I was talking with my co-workers and they said the same thing, it is better I subclas the server control and override the render method.
Cleiton
+1  A: 

I would go for HttpModule and a ResponseFilter. Use RegEx to find the br tags, and replace them with String.Empty before the response is sent to the client.

BurningIce
woww... I didnt know that! I will give a try.
Cleiton