teshio
teshio

Reputation: 41

How to control placement of control in code behind

Is it possible to control the placement of a generated control in asp .net 2.0 (c#)?

So for example in my page_load I create a new Panel() and then do Form.Controls.Add(pnl). However I'm finding it renders right at the end of the form.

I would like it rendering as the first element in the form.

Upvotes: 1

Views: 134

Answers (2)

fearofawhackplanet
fearofawhackplanet

Reputation: 53378

Have you considered using a PlaceHolder control?

Upvotes: 0

rahul
rahul

Reputation: 187020

You can use

Controls.AddAt() method, which adds the specified Control object to the collection at the specified index location.

Upvotes: 1

Related Questions