Click here to Skip to main content
15,891,782 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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;
               cell.Controls.Add(label);


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?
Posted
Updated 30-Oct-13 9:32am
v2
Comments
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 asp.net 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
getMainPanel().Controls.Add(paramTable);

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.

—SA
 
Share this answer
 
Comments
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.
—SA
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.
—SA
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.
It was the Compatibility Mode in IE10, once I turned it on for that site it worked fine.
 
Share this answer
 

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

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900