Here is an example to show a more detailed user information (an User Control) in UserProfile.ascx:
1. Reference the control located in folder: Components:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="UserProfile.ascx.cs"
Inherits="Components_UserProfile"%>
<%@ Reference Control="~/Components/UserInfoLarge.ascx" %>
Larger View
2. In UserProfile.ascx.cs page:
protected void lnbUserInfoLarge_Click(object sender, EventArgs e)
{
string sUserName = txtUserName.Text.Trim();
Components_UserInfoLarge userInfoLarge = (Components_UserInfoLarge)LoadControl("~/Components/UserInfoLarge.ascx");
userInfoLarge.sUserName = sUserName;
panelUserInfoLarge.Controls.Add(userInfoLarge);
}
3. In the User Control: Components/UserInfoLarge.ascx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class Components_UserInfoLarge : System.Web.UI.UserControl
{
private string _sUserName = "";
public string sUserName
{
get
{
return _sUserName;
}
set
{
_sUserName = value;
//if the public sUserName is changed outside
//for example: userInfoLarge.sUserName = sUserName in above code
//then refresh this control by calling this: populateData()
populateData();
}
}
protected void populateData()
{
if (_sUserName.Length > 0)
{
DataSet ds = new DataSet();
ds = getUserInfoFromDB(_sUserName);
if (ds != null)
{
//do whatever you want...
}
}
}
}