I have just a simple message page which consists of From: Text: and a Submit button, then I have another page, which contains nothing, it’s my "Message Board" the most recent posted message goes on top of the board, both are aspx pages with master page.
I have a SQL DB, I’m already assuming there will be a table with From: Message:(with varchar i think), but what i don’t understand how it will get inserted into the messageboard page in a most recent to oldest list fashion.
Message.aspx – From: Text: Submit
MessageBoard.aspx – just a div , messages submitted will appear here in a drop down list
I want it to be super simple no cool features, only "Submit the message" -> "Appears on MessageBoard.aspx to everyone",
and that’s it
2
Answers
You don’t explain what you mean by "what i don’t understand how it will get inserted into the messageboard page in a most recent to oldest list fashion", so I can only guess.
When a new message is posted, you insert it into the database, including a
DateTime
column. Your message list page then just grabs the latestnn
messages, ordered by newest first.I’m assuming that you know how to do that. If not, do some reading about Entity Framework Core, as that provides a very good way of handling databases.
So, in princple, your question is no more complex than that. However, there are many variations on this, such as having the message list updated in real time, for which you should use SignalR, but without more specific explanation of what you want, it’s hard to make any suggestions.
Ok, there are seveal moving parts.
Assuming you have SQL server running. Assuming you have a valid conneciton?
Ok, then on the post a new message page, you have this markup:
And code behind looks like this:
So, it looks like this:
when you hit post message, we jump to this page, and markup:
And code is:
And we now see/have this: