Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help displaying data

Status
Not open for further replies.

Cenedra

Programmer
Jan 2, 2003
114
US
Here is my scenario. I have a users that have profile, and they fill out a series of questions about themselves. All the questions aren't required.

When I just display them, I only want to display the items the user has filled out. I have this logic down.

However, when I display my data, what is the best way to do so? Some of my items are multi-line text fields the user fills out, and when I display the data onto the screen in my view profile page the text does not wrap and makes my page very long horizontally (I am displaying in a label). I want to contain it into a specific area.

My entire web page is all comprised of user controls, and the user control I am displaying this data in is only the maximum width I want for the area, however displaying the data isn't following the width constraints I put on my table.

Any suggestions?

Thanks in advance,
Cen
 
If you display data in a div tag, you can set it's maximum width and height properties and set the overflow to auto so that scrollbars will be created for the div tag if the content exceeds the width or height.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
What if I don't want scroll bars and just want all the data output? Do I not set a height for the div and that will work?
 
Exactly. Don't set the height property, and the div will expand to fit. Also, keep in mind that ASP.NET is a language or tool for generating HTML. You don't have to use a Web Control (like a label). Just output the content of your strings within a DIV, as has been suggested.

Thomas D. Greer

Providing PostScript & PDF
Training, Development & Consulting
 
I've never output my content in a div before, do you have a sample I can look at?

Thanks very much for your help!
 
You can place your content into a <div> dynamically using JavaScript by setting the div's ".innerHTML" property:

Code:
var mystring = "A string of content.";
document.getElementById("myDiv").innerHTML = mystring;

If you wanted to do this server-side, look at using the PlaceHolder web server control, which has an "Add()" method.

Thomas D. Greer

Providing PostScript & PDF
Training, Development & Consulting
 
or you could do the obvious and use a table.
there are plenty of ways to force text to wrap in a table.

-Jer
 
I did use the "obvious" table and divs inside and it was still not wrapping.
 
have you tried anything like setting your table width to 100%?

-Jer
 
or you could do the obvious and use a table.
there are plenty of ways to force text to wrap in a table.
It may be "obvious" to you, but it is in fact quite bad practice. CSS (like using div tags) should be used instead of using tables.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
why would you even substitute a table with a div?
For lots of reasons. e.g.

1) Cross-browser compatibility
2) Easy Maintenance

There are lots of articles on this subject, a couple of which are:



____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.
 
I took ca8msm's advise and wrote a site with 99% div tags (1 Table). Took some getting used to but now I love it.
 
Took some getting used to but now I love it.
Exactly the same experience as when I first started using CSS. It gives so much more control and the maintainability (is that a word?!) of it is so much easier.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
but [using tables] is in fact quite bad practice
God help us. We have billions...trillions....googols of webpages out there built on tables. Where did all these developers learn how to design a webpage?!

you know it's really designer preference not bad practice.

1) Cross-browser compatibility

if some one has a problem displaying a table in their browser, they've got more serious problems.

And CSS is definately more prone to compatibility issues.

-Jer
 
God help us. We have billions...trillions....googols of webpages out there built on tables. Where did all these developers learn how to design a webpage?!
And because lots of people do it means that it is good does it? CSS has been introduced a lot longer after HTML first came about (in which tables were generally the only thing that was used to provide positioning). CSS was then introduced as a cross-browser way to have a way of designing pages so that tables didn't have to be used.

if some one has a problem displaying a table in their browser, they've got more serious problems.
It's not that someone will have problems actually displaying a table, it's how the table is actually rendered (i.e. it appears different on different browsers).

And CSS is definately more prone to compatibility issues.
How?

I'm sure if you would like to start a discussion on tables vs CSS, we could start a thread in the HTML forum where we will get a lot of expert opinons (and they will all favour CSS - and probably give a lot more detailed answers on why it is better).


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
I'm sure if you would like to start a discussion on tables vs CSS, we could start a thread in the HTML forum where we will get a lot of expert opinons (and they will all favour CSS - and probably give a lot more detailed answers on why it is better).
No, that's ok. I don't doubt that they would agree, but to say that a table is bad practice is presumptuous.

unfortunately (well, not really), since html and css are non-proprietary and are only really based on recommendations and you know Microsoft thinks they own the world...heck who cares. what a waste of time.

-Jer
 
No, that's ok. I don't doubt that they would agree, but to say that a table is bad practice is presumptuous.
If you do any sort of web development that involves multiple browsers like I do, you want the site to look as expected. Using tables, in lots of cases, means that it is displayed differently between browsers and is therefore not displayed as I would expect (sometimes with horrible consequences!). To me, as a developer, that is bad practice which is why I use CSS, as it has proven not to do this (hence not presumptuous as it is based on experience not an assumption).


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
If you do any sort of web development that involves multiple browsers like I do, you want the site to look as expected.

Who doesn't? You have to. If you are anything beyond a beginner you are going to consider browser compatibility.

You know the whole point of this post is to deal with text wrap not the width and color of a border.


-Jer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top