O
Oleg Ogurok
Hi all,
In my page class, I'm loading a user control:
private void Page_Load(object sender, System.EventArgs e)
{
Control c = LoadControl("WebUserControl1.ascx");
Controls.AddAt(0, c);
}
Inside WebUserControl1.ascx I have a hyperlink whose NavigateUrl property is
set at runtime (e.g. in Page_Load). Here's the code form
WebUserControl1.ascx.cs
private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
HyperLink1.NavigateUrl = "/SomePage";
}
The problem is that if my page has a control that causes postback (e.g.
Button), the next time the page loads, the hyperlink inside the user control
doesn't retain its NavigateUrl property. I'm wondering why this is
happening.
In my scenario, I can't drop the user control (ASCX) on the page, because
the page is a bare .cs class (base page) without ASPX.
Thanks,
-Oleg.
In my page class, I'm loading a user control:
private void Page_Load(object sender, System.EventArgs e)
{
Control c = LoadControl("WebUserControl1.ascx");
Controls.AddAt(0, c);
}
Inside WebUserControl1.ascx I have a hyperlink whose NavigateUrl property is
set at runtime (e.g. in Page_Load). Here's the code form
WebUserControl1.ascx.cs
private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
HyperLink1.NavigateUrl = "/SomePage";
}
The problem is that if my page has a control that causes postback (e.g.
Button), the next time the page loads, the hyperlink inside the user control
doesn't retain its NavigateUrl property. I'm wondering why this is
happening.
In my scenario, I can't drop the user control (ASCX) on the page, because
the page is a bare .cs class (base page) without ASPX.
Thanks,
-Oleg.