我有一个带有几个文本框的用户控件。我在 UC 上创建了属性以将文本框设置为这些值。
在我的页面上,我在面板内有一个占位符,用于显示为弹出窗口的用户控件。当我加载用户控件时,我设置了它的属性,但是当弹出窗口显示没有一个文本框设置它们的值时。
不知道我哪里出错了,这里有一些代码:
页:
public void LoadFiguresControl()
{
var mgr = new CompaniesBusinessManager();
WebParts_CreateOwnershipFigures fig = (WebParts_CreateOwnershipFigures)Page.LoadControl("~/WebParts/CreateOwnershipFigures.ascx");
if (ddlEditCompanies.SelectedValue != null && ddlEditCompanies.SelectedValue != "")
{
var cc = mgr.GetOwnershipCompanies(rlabs.letsema_re.Domain.CompanyQueries.GetOwnershipCompaniesType.By_Id, int.Parse(ddlEditCompanies.SelectedValue), -1).FirstOrDefault();
if (cc != null)
{
fig.OwnershipCompanyId = cc.Id;
fig.CompanyTitle = mgr.GetCompanies(cc.CompanyId.Value).FirstOrDefault().Name;
fig.Shareholding = (cc.ShareholderPerc.HasValue ? cc.ShareholderPerc.Value : 0);
fig.Black = (cc.BlackPerc.HasValue ? cc.BlackPerc.Value : 0);
fig.RSA = (cc.RSAPerc.HasValue ? cc.RSAPerc.Value : 0);
}
}
PlaceHolder1.Controls.Add(fig);
}
用户控件的属性示例:
public string CompanyTitle
{
get
{
return lblOwnership.Text;
}
set
{
lblOwnership.Text = value;
}
}
并显示弹出窗口:
protected void btnEdit_Click(object sender, EventArgs e)
{
LoadFiguresControl();
ModalPopupExtender1.Show();
}