Hello all,

I'm drawing a blank on how I should proceed with the final steps in completing my website. I guess to sum it up is I would essentially like to let the users be able to submit something that shows up on the home page and stays there (this being text that they've entered in a textbox).

I was originally going to do this through an arraylist in VB but my instructor said that it would be pretty nasty using an AL because I would have to code around the fact that I'm not going to know every specific ID that is being created since the controls would be created dynamically.

Then he mentioned just having them saved to a database and then running a stored procedure that would cycle through the saved items and have them displayed through a data view control.

What do you guys think would be the best, and simplest, way to make this happen?

Here is the run-down: I have 2 textboxes and a button. The first textbox is the title of what the user is writing and the other is the actual story. When the button is clicked I want it to take what was written in those 2 boxes and then make them appear in newly created labels (since it will be read only) and stay after post back.

I'm not asking for code as that would really defeat the purpose of me trying to learn how to do it and do it correctly but more or less just some suggestions on how to do it correctly.

Thanks guys!

Recommended Answers

All 4 Replies

I would tend to agree that one viable option is to take the information from the textboxes, save them to a database table. Then use one of the asp.net controls in your toolsbox, such as a repeater, or a datalist and display the results on the page.

One question, those inputs are going to stay on the page only for the current user session or they must appear in the next visits as well?

In the first case, I'd save them in the Session, using an List<UserInput>. Where UserInput is a class with Title and Text properties.

In the second case, I'd save them on the DB and also would use an List<UserInput> for retrieving the saved itens from the DB.

Then, to show the saved itens(either from DB or Session) I suggest you to use a Repeater, as recommend by JorgeM.

The best thing about creating your own class to store the itens is that you can sofisticate it later, adding more information.

Thanks for the responses guys. I'll look into a repeater as I've never heard of that control before.

@AleMonteiro yes I want the items to stay on the home page for multiple visits for multiple users; not just the current user session. Essentially I want the inputs to stay up for days (I'll probably code something to limit the time they appear later) so other users that visit can read them as well.

I wanted to compare it to a "comments" section but I didn't want to explicitly say comments as I thought that might confuse someone.

I see, that's it them. You can create a UserComment class to hold all the data, including Title, Text, UserName, Comment DateTime and so on.

I suggest you start by defining your database structure. I mean, you probably already have a Users table, so you'll need to create an UserComment table, or something like that.

Once you have your database created, creating the Class is much more simpler.

Good luck.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.