So I want to add a asp button after my I create a new instance. I'm having trouble giving the button a name, id, etc. Like so <asp:Button ID="Button1" runat="server" Text="Button" /> I'm unable to do this because everytime I try to add parenthesis " " it won't work. Also, I want to be able to give all the Logs a seperate id for each button created. I'm also having trouble removing the output that its creating in the top left hand side corner, why is this appearing twice? I just want it to appear ONCE in the middle of the page! Keep in mind, I've search alot of places for this but there are no answers. Any help, I will provide all the code below that is need. Thanks!


public class WelcomeText
    public string Greet;
    public string Name;
    public DateTime Visited;

    public WelcomeText(string greet, string name, DateTime visited)
        Greet = greet;
        Name = name;
        Visited = visited;

    public void greetUser(string msg)
        HttpContext.Current.Response.Write(msg + Greet + " " + Name + " " + Visited + "<button></button><br/>");


    <form id="form1" runat="server">

Code behind:

public partial class WebForm1 : System.Web.UI.Page
        public delegate void greetDel(string msg);

        protected void Page_Load(object sender, EventArgs e)
            // display text

        public string displayWelcomeText()
            string greetString = "";
            WelcomeText wT1 = new WelcomeText("Welcome", "Sean", DateTime.Now);
            WelcomeText wT2 = new WelcomeText("Hey", "Test", DateTime.Now);
            WelcomeText wT3 = new WelcomeText("Hello", "User", DateTime.Now);

            greetDel gD1 = new greetDel(wT1.greetUser);
            gD1("Log: ");

            greetDel gD2 = new greetDel(wT2.greetUser);
            gD2("Log: ");

            greetDel gD3 = new greetDel(wT3.greetUser);
            gD3("Log: ");

            return greetString;

Problem with my code Problem

Related posts

Recent Viewed