Reputation: 1309
I'm adding controls to a panel on an Asp.Net webforms page and I'd like to change the html it generates. A simplified example of what I'm doing:
Dim control1 As New HiddenField()
control1.ID = "Control1"
control1.Value = "Text"
Dim control2 As New HiddenField()
control2.ID = "Control2"
control2.Value = "Text"
Panel1.Controls.Add(control1)
Panel1.Controls.Add(control2)
This generates the following HTML:
<input type="hidden" name="Control1" id="Control1" value="Text" /><input type="hidden" name="Control2" id="Control2" value="Text" />
Is there a way to ensure that there's a newline in between every control? The current source is a pretty big mess when you add more controls. I'd like the html to be formatted like this:
<input type="hidden" name="Control1" id="Control1" value="Text" />
<input type="hidden" name="Control2" id="Control2" value="Text" />
Upvotes: 2
Views: 161
Reputation: 19953
Assuming both controls should be added to Panel1, try this...
Panel1.Controls.Add(control1)
Panel1.Controls.Add(New LiteralControl(Environment.NewLine))
Panel1.Controls.Add(control2)
Upvotes: 2
Reputation: 13600
If you don't like how certain control generates itself, you can always create one yourself. This is a fairly simple example and I'm sure you'd have it done it few minutes.
Upvotes: 0