Tuesday, October 4, 2011

Change the name of the LoginName controller in ASP.net

I came across the situation that user need to change the name of the LoginName controller when user change his or her name so that what I did was I include following code.



LoginView loginView = (LoginView)Master.FindControl("UBLoginView");
LoginName loginName = loginView.FindControl("UBLoginName") as LoginName;
loginName.FormatString = FullName.Text;


in first line Find and instantiate the LoginView from the master page otherwise if you try to directly instantiate the LoginName it will throw a null reference exception. Now you all know what the use of second line is, and finally equal new name to LoginName.

0 comments:

Post a Comment