Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any alternative for <br /> in asp.net?

Tags:

html

c#

asp.net

I was trying to display lblName1 and lblName2 only if they have text. Even when i dont have any value for lblName2, the break still has an impact. Can someone please advice me if there is any other way to display
or conditionally display

<asp:Label ID="lblName1" runat="server" Visible= "false" ></asp:Label> <br />
<asp:Label ID="lblName2" runat="server" Visible= "false">  </asp:Label>

Thanks in advance..

like image 893
Remo Avatar asked Sep 01 '25 18:09

Remo


2 Answers

Give the label a CSS class name and set the margin for that class:

<asp:Label ID="lblName1" CssClass="Testing123" runat="server" Visible= "false" ></asp:Label> <br />

.Testing123{ margin-bottom: 20px; }

If the Label is not rendered then no gap will be created.

like image 54
Jason Evans Avatar answered Sep 04 '25 08:09

Jason Evans


You might consider adding a litteral to handle the br and this way play with its visibilty :

<asp:Literal runat=server Id=C_lit_Br><br /></asp:Literal>

with in your codebehind :

if (!lblName2.Visible)
    C_lit_Br.Visible=false;

It is a quick patch, but it should work.

like image 39
Arthis Avatar answered Sep 04 '25 06:09

Arthis