c# - How to append a WebControl immediately after a WebControl in CodeBehind -



c# - How to append a WebControl immediately after a WebControl in CodeBehind -

now i've been mvcing quite sometime decide pop classic c# .net 8 track , have gotten next issue:

i have textbox webcontrol on aspx page in code behind want append literalcontrol after it.

this doesn't work:

textboxage.controls.add(new literalcontrol("invalid age."));

this works way @ bottom:

textboxage.controls.parent.add(new literalcontrol("invalid age."));

can help me!?

for illustration html show:

<div> <input name="textboxage" type="text" id="textboxage" class="age"> invalid age. </div>

this should purely dynamic , relative command @ hand.

solution:

textboxage.parent.controls.addat(textboxage.parent.controls.indexof(t‌​extboxage),new literalcontrol("<span>invalid age.</span>"));

maybe can seek this. (don't remember if addat replace command @ specified index )

var textboxageindex = textboxage.parent.controls.indexof(textboxage); textboxage.parent.controls.addat(textboxageindex +1, new literalcontrol("invalid age."));

hope help

c#

Comments

Popular posts from this blog

javascript - mongodb won't find my schema method in nested container -

Hibernate criteria by a list of natural ids -

ios - Lagging ScrollView with UIWebview inside -