Wednesday, March 28, 2012

Why LoginView cannot be added to PlaceHolder?

I tried to add a LoginView control in OnClick eventhandler of a
button.
The code is like below

LoginView login = new LoginView();
PlaceHolder1.Controls.Add(login);

After run the page, I click the button and nothing happens.

If I change LoginView to a Label, it shows.
Why this happens? Should I set some properties to LoginView before add
it to PlaceHolder Control?on postback your code has to remember it added on the LoginView on page
render. the LoginView needs to be re-add in the postback oninit.
otherwise there is no control to handle the postback data.

-- bruce (sqlwork.com)

Morgan Cheng wrote:

Quote:

Originally Posted by

I tried to add a LoginView control in OnClick eventhandler of a
button.
The code is like below
>
LoginView login = new LoginView();
PlaceHolder1.Controls.Add(login);
>
After run the page, I click the button and nothing happens.
>
If I change LoginView to a Label, it shows.
Why this happens? Should I set some properties to LoginView before add
it to PlaceHolder Control?
>

0 comments:

Post a Comment