Solved

asp.net - not allowed to increase the width of a WebControls.Label inside a HtmlTable cell

Posted on 2008-10-20
4
444 Views
Last Modified: 2012-05-05
The problem is shown in the attached screen shot.

The problem is that the label that i have selected wont span the length of the table. The annoying thing about this is that it USED to, but for some reason one day i loaded the project and it shortened itself and now i cant make it bigger.

You can see by the properties there is no explicitly set Width of the label, and that the text wraps itsself because the label size is somehow set to a fixed value.

What causes this and how can i fix it?
problem.JPG
0
Comment
Question by:tfsln
  • 2
4 Comments
 
LVL 8

Expert Comment

by:mkosbie
ID: 22762166
Is there some CSS set on it perhaps?  Try removing the style properties and any CSS class to see if it spans properly.  If so, then add them back one by one until you find the culprit.
0
 

Author Comment

by:tfsln
ID: 22762214
Where it used to say <td class="style28"> it now just says <td>.
It fixed it, but is it possible to cause any other issues? I dont use stylesheets in my application, but i notice that every other row has a style except this one now... (and they all work fine)
0
 
LVL 8

Accepted Solution

by:
mkosbie earned 500 total points
ID: 22762254
Whatever IDE your using probably is creating stylesheets for some of your formatting in the background.  Look in the head section of you code for a style element similar to this:

<style type="text/css">
<!--
// various style declarations
.style28 {
    width: 15px; //some width
    //other declarations on this style
}
-->
</style>

Find the line that has width in it for style28 and delete it, then put the class back so any other formatting you have will work.  If that doesn't help, or you don't see a width line, past style28 here and we'll look at it.
0
 
LVL 16

Expert Comment

by:GreymanMSC
ID: 22762294
To force the label to fit the width of the containing cell, simply set the Width attribute to 100%.

<table id=AnExample>
  <tr valign=top>
    <td style="border-color:red;border-style:solid;border-width:thin" 
       width=200px
    ><asp:Label ID=Elle runat=server 
        BorderColor=Blue BorderStyle=Solid BorderWidth=2px 
        Text="Hello World" 
        Width=100%
       ></asp:Label></td>
  </tr>
</table>    

Open in new window

0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

823 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question