Click here to Skip to main content
14,640,670 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi, I am working on a web application that dynamically loads controls based on user preferences. The Labels and Textboxes are being loaded at run time. When my boss deployed it to a new webserver the label widths were not rendering to the browser but, it works fine for me running it from Visual Studio 2010. We are both using IE10. The web server is a Windows 2008 R2 running IIS7.5. Here is how I create the control:
cell = new HtmlTableCell();
               Label label = new Label();
               label.Text = props.LabelText;
               label.Width = 150;

When I view the source code on my machine it looks like this:
<td><span style="display:inline-block;width:120px;">Company:</span></td>

Source code from the server looks like this:
<td><span style="display:inline-block;">Company:</span></td>

Width is dropped, has anyone come across this before?
Updated 30-Oct-13 9:32am
Richard C Bishop 30-Oct-13 15:32pm
Where are you adding the HTMLTableCell to the page?
Member 7818637 30-Oct-13 15:51pm
Hi Thanks for answering so quickly, I am assembling the table then adding it to a panel:
Here is that code:
//This function loops the fields and creates the table
HtmlTable paramTable = BuildParamerterControls(oReportParams, oOrderList, oReportFileBEC.FileName);
//Then gets written to the panel
Rate this:
Please Sign up or sign in to vote.

Solution 1

That's correct: on inline elements, width is insignificant; such elements only occupy as much space as it it required to render them.
What to do? It depends on the layout you want to achieve. You can modify display type, wrap this element in some other element like div or modify layout of outer HTML (is it "td"?), work with margins and/or padding, etc.

Member 7818637 30-Oct-13 17:27pm
Then why does it work on our other servers. We have been building this application for 6 months and use this layout on about 100 pages. Our 3 development servers display them all fine and the source code shows the width of 150px in the span that the server renders from the control. Only this new server we just set up is having this issue.
Sergey Alexandrovich Kryukov 30-Oct-13 17:31pm
Are you sure the resulting HTML (CSS and all that) is the same? It could not be. Rendering knows nothing about servers, it depends only on the browser.
Member 7818637 30-Oct-13 17:40pm
Yes, It is just a copy of the site to a new server and the code behind is the only place I am adding any style to the control. So we though it maybe a server setting we are missing since this is a new server.
Sergey Alexandrovich Kryukov 30-Oct-13 17:59pm
No. Client sides knows nothing about server settings. Your observations are not quite accurate, that's it.
Member 7818637 30-Oct-13 18:04pm
I appreciate you trying to help me. I know the client knows nothing about the server. But the server renders the HTML from the ASP.NET controls and it is not reading or dropping the width on this server before rendering it. Hopefully someone else can help.
Sergey Alexandrovich Kryukov 30-Oct-13 18:18pm
Maybe, but you need to double check your information.
Rate this:
Please Sign up or sign in to vote.

Solution 2

It was the Compatibility Mode in IE10, once I turned it on for that site it worked fine.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100