Visual Web Developer: Adding Text Dynamically

116 Views Asked by At

I am designing a web page (in Visual Web Developer) that displays a report in graphical form. Once the graphics are seen some comments need to be appended underneath. This can only be done after the graphics have been rendered since the comments will be based on that output.

I need a way to prompt for comments and display them as an ordered list. I thought I could use a textbox with some buttons and replace these with the ordered list when the "Done" button gets clicked -- ie, the textbox and buttons disappear and in their place is the ordered list of comments.

I have hacked and Googled myself silly but I haven't come up with a solution.

Any advice is appreciated.

Regards.

2

There are 2 best solutions below

0
On BEST ANSWER

I solved this problem by replacing innerHTML like this:

protected void SubmitMessages()
{
    string[] lines = MessagesTextbox.Text.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
    string output = "<ul>";
    foreach (string message in lines)
    {
        if (!message.Equals(""))
        {
            output += "<li>";
            output += message;
            output += "</li>";
        }
    }
    output += "</ul>";
    messagesDiv.InnerHtml = output;

    //string messagesFileLocation = AppDomain.CurrentDomain.BaseDirectory + "/mesages.xls";
    string messagesFileLocation = "D:\\WebApp\\messages.xml";
    FileStream fs = File.Open(messagesFileLocation, FileMode.Create, FileAccess.Write);
    if (lines.Length != 0)
    {
        using (StreamWriter sw = new StreamWriter(fs))
        {
            sw.WriteLine("<Messages>");
            foreach (string message in lines)
            {
                if (!message.Equals(""))
                {
                    sw.WriteLine("\t<message>" + message + "</message>");
                }
            }
            sw.WriteLine("</Messages>");
        }
    }
}
0
On

Have you considered Ajax? Do whatever you need and after that make an ajax request to retrieve the comments as needed.