I'm trying to make the following piece of code to work.

Login LoginControl = (Login)PreviousPage.FindControl("Login1");
if (LoginControl != null)
{
TextBox UserName = (TextBox)LoginControl.FindControl("UserName");
if (UserName != null)
{
Label1.Text = UserName.Text;
}
}
else
{
Label1.Text = "Cannot find user name in Login control.";
}

This is an example supplied by the following website:

http://msdn.microsoft.com/en-us/library/ms178139.aspx

However, I don't know how to declare the page Login as a class other pages can use. The actual source code lists Login as a partial class, so I assume there is some property which needs to be set in order to be used as a normal class. Intellisense also is not locating the Login class when I try to use it in a different page.

Member Avatar for stbuchok

Please read the entire article. It says that Login is a User Control, there is even a link to another page that goes into more detail about the Login Control.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.