Here is the code (content is the name of my <div>):

foreach (Exercise ex in exs)
            {
                Label label = new Label();
                label.ID = Convert.ToString(ex.ex_id);
                label.Text = ex.ex_text;               
                TextBox textbox = new TextBox();
                textbox.Width = 100;                
                textbox.ID =Convert.ToString(ex.ex_id);
                id_counter++;
                content.Controls.Add(label);
                //content.InnerHtml += "<br />";
                content.Controls.Add(textbox);
            }

It crushes on the content.Controls.InnerHtml+="<br/>" thingy.
I tried wihtout the space in the < > it wouldn;t work either :S.
I usually use content.innerhtml though dunno why it wun work here.
I tried setting it in a variable but this wonlt work either same error.
Anyone knows why it happens ? I always use this content.inner html in my functions :S...

Recommended Answers

All 2 Replies

use LiteralControl l1 = new LiteralControl("<br/>"); to create <br/> html tag

Solved
I added

content.Controls.Add(new LiteralControl("<br />"));

though I still dun get why simply adding the br as I usually do isn;t good all of a sudden it was good in all places where I didn;t deal with controls...

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.