[RESOLVED]Question about solid white border

Hello

I have some text that displays the results of a file upload. In my aspx file, I have:

  <asp:Label ID="Label1" CssClass = "formattedText" runat="server"></asp:Label>

and the CSS for it is:

 .formattedText {
font: normal 14px 'Droid Sans','Trebuchet MS', Arial, sans-serif;
color:#ffffff;
/*float: right;*/
position:absolute;
top: 330px;
border: 1px solid white;
padding:15px;
}

This is the text when a file has been uploaded:

Border1

However, before a file has been uploaded, I can see this empty square box on the same upload page:

Empty box

How can I remove that empty square box while keeping the box to house the text after a file has been submitted?

Thank you.

Bluenose

How can I remove that empty square box while keeping the box to house the text after a file has been submitted?

One suggestion is to set the visibility of your label to hidden using css and then later make it visible from serverside(C#)

Change you css style like given below to hide the label initially

<style>
        .formattedText
        {
            font: normal 14px 'Droid Sans' , 'Trebuchet MS' , Arial, sans-serif;
            color: #ffffff; /*float: right;*/
            position: absolute;
            top: 330px;
            border: 1px solid white;
            padding: 15px;
            display:none;
        }
    </style>

Later once you fill the details in label control in serverside use the below code to make visible.

 //Code to fill the label with details of file uploaded

            //Show the label after filling the data
            Label1.Style.Add("display", "block");

Hello A2H

Thanks for your reply.

Do you mean like this:

 <asp:Label ID="Label1" CssClass = "formattedText" Label1.Style.Add("display", "block"); runat="server"></asp:Label>

I get an error under Label1.Style.Add: ‘This attribute name must be followed by an equal (=) sign and a value. If the value is in quotation marks, the quotation marks must match’.

Not too sure what that means!

Bluenose

Hello A2H

Thanks for your reply.

Do you mean like this:

 <asp:Label ID="Label1" CssClass = "formattedText" Label1.Style.Add("display", "block"); runat="server"></asp:Label>

I get an error under Label1.Style.Add: ‘This attribute name must be followed by an equal (=) sign and a value. If the value is in quotation marks, the quotation marks must match’.

Not too sure what that means!

No, You are trying to add the code in HTML itself. You need to add that code in Serverside(c#) code. for ex: if you have a page called webform1.aspx , the add the below line of code in webform1.aspx.cs page

c#:

Label1.Style.Add("display", "block");

Vb.Net:

Label1.Style.Add("display", "block")

I agree that the best way to handle this would be to explicitly hide the element (through the display: none; CSS attribute) and keep the border styles on your CSS class until you need to show the element itself.

So basically, you would keep your existing styles on your CSS class and hide your particular element by default :

<!-- The display: none attribute will initially hide the element -->
<asp:Label ID="Label1" CssClass = "formattedText" runat="server" style='display:none;'></asp:Label>
 

Then when you populate the values within your Label, simply display the label by removing the hidden style :

// Set the content for your Label
Label1.Text = "Example!";
// Display the element
Label1.Attributes.Add("style","display:block");

There are a variety of ways to handle this, but this should work just fine.

Very many thanks to you both!

It looks far better now. I didn’t know that attribute even existed!

Thank you again.

Bluenose

looks far better now. I didn’t know that attribute even existed!

Thank you again.

You are welcome

Leave a Reply