我的用户控制有问题。我无法从usercontrol调用方法。 我的default.aspx包含Update面板。因为我不想要重新发布页面。
我的default.aspx页面是:
public partial class Page_Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Load();
}
private void Load()
{
if (Session["User"] == null)
{
ApplicationController.Controls.Add(new UserControl().LoadControl("View/Public/Login.ascx"));
}
else
{
ApplicationController.Controls.Add(new UserControl().LoadControl("View/Public/Welcome.ascx"));
}
}
}
和动态添加的UserControls是:
public partial class View_Public_Login : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnAssetsGiris_Click(object sender, EventArgs e)
{
var user = new Kys.Dbo.Assets.user()
{
UserId = txtEmail.Text.Trim(),
Pwd = txtPwd.Text.Trim()
}.Login();
if (user != null)
{
Session["User"] = user;
}
}
}
如何从用户控件中调用Load()
方法?
答案 0 :(得分:0)
var usercontrol = (View_Public_Login ).LoadControl("View/Public/Login.ascx");
usercontrol.Load()....
ApplicationController.Controls.Add(usercontrol);