(New to ASP.NET here.)
I have a user control which should check for a value in the request query string before deciding what to render:
<%# softLoaded ? "HELLO" : "GOOD BYE" %>
This is the code-behind for the user control:
public bool softLoaded { get; set; }
protected void Page_Load(object sender, EventArgs e)
{
softLoaded = "apply".Equals(Request.QueryString["apply"]);
}
I've debugged the application and found that softLoaded
is true
when it should be and false
when it should be, but no matter what the value is, the generated HTML says "GOOD BYE" (as if the value was false
). This makes me believe that Page_Load
is called "too late", causing the .ascx
file to use the default value of the bool, which is false
.
What am I doing wrong? How do I solve this?