Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to not render a Panel Control as a <div>

Tags:

c#

asp.net

panel

I use Asp.net 4 and C#.

I have a common web control <asp:Panel>. It is my understanding that if the Panel is visible it renders in the Browser as a <div></div> tag.

I would like to know if is possible to change this behavior and display the content of the Panel without rendering its <div>.

  • Any idea how to do it?
  • Can I use another control instead of Panel?

An example of code would be appreciated thanks!

like image 972
GibboK Avatar asked Sep 19 '11 14:09

GibboK


2 Answers

Simple :

use PlaceHolder or  Literal

it renders only what it has - nothing more nothing less.

like image 196
Royi Namir Avatar answered Oct 07 '22 17:10

Royi Namir


If you use an ASP.NET PlaceHolder control then you will not get the div tags.

Of course if you use a PlaceHolder you will not get a HTML element for this (i.e. a DIV tag) so you cannot set properties such as BackImageUrl or Wrap, etc. on the control.

like image 27
Jonathan Williams Avatar answered Oct 07 '22 16:10

Jonathan Williams