Hej, jeg har siddet super længe og bakset med dette kodeværk, der bare ikke vil virke.
Målet er at lave et forum, koden giver fin mening i sig selv, men min "ForumEntry" vil ikke populate min "Entries", der ellers er en "IList<ForumEntry>"
Thread.aspx.cs
- namespace Forum
- {
- public partial class Thread : System.Web.UI.Page
- {
- private Int32 ThreadIdentifier;
- private IList<ThreadEntry> Entries;
- protected void Page_Load(object sender, EventArgs e)
- {
- this.ThreadIdentifier = Convert.ToInt32(Request.QueryString["ID"]);
-
- populateThread();
- showthreads();
- }
-
- public void populateThread()
- {
- ThreadEntry entry = new ThreadEntry(this.ThreadIdentifier);
- entry.ThreadName = "abe";
- entry.EntryID = 1;
- entry.UserID = 1;
- entry.NickName = "T1MeW4sTeR";
- entry.Text = "Dette er det først indlæg i en ellers lang tråd. :)";
- entry.datetime = "hh";
-
- this.Entries.Add(entry);
- }
-
- public void showthreads()
- {
- foreach(ThreadEntry entry in this.Entries)
- {
- DivEntries.InnerHtml += "Nickname: " + entry.NickName.ToString();
- DivEntries.InnerHtml += " Time: " + entry.datetime.ToString();
- DivEntries.InnerHtml += "<br /><br />" + entry.Text.ToString();
- }
- }
- }
- }
Thread.cs
- namespace Forum
- {
- public abstract class ForumThread
- {
- public Int32 ThreadID;
- public string ThreadName;
- }
- }
ThreadEntry.cs
- namespace Forum
- {
- public class ThreadEntry : ForumThread
- {
- public Int32 EntryID;
- public Int32 UserID;
- public string NickName;
- public string datetime;
- public string Text;
-
- public ThreadEntry(Int32 id)
- {
- this.ThreadID = id;
- }
- }
- }
Er der ikke en, der kan hooke mig up med en lækker løsning?