Algernon83
Programmer
I've made a custom web control, but I find that when I use it, the properties of it are not set as I expect, and I get a null reference exception when opening the page. What is the correct format for setting object properties of a web control? More detail follows, if necessary:
The control is for security purposes. Specifically, it is meant to check whether the user currently logged in is a member of one of a set of groups, showing different content depending on the answer. The control class (CheckPoint) has two members, Success and Failure, each of which is a ControlCollection that defines the content to show in case of success (user in appropriate group) or failure. I currently have it on the page in the following format:
<Security:CheckPoint runat="server">
<Groups>
<asp:ArrayList>
<asp:Int16>1</asp:Int16>
</asp:ArrayList>
</Groups>
<Success>
Hello, world!
</Success>
<Failure>
Goodbye, world!
</Failure>
</Security:CheckPoint>
Groups is a bit clunky; I'll probably change it to a delimited list eventually. At any rate, even if I reduce the CheckPoint class's Render method to:
foreach (Control c in this.Success)
{
c.RenderControl(output)
}
I receive a null reference error. Do non-scalar properties of controls need to be set programatically, e.g. in the page_load event?
The control is for security purposes. Specifically, it is meant to check whether the user currently logged in is a member of one of a set of groups, showing different content depending on the answer. The control class (CheckPoint) has two members, Success and Failure, each of which is a ControlCollection that defines the content to show in case of success (user in appropriate group) or failure. I currently have it on the page in the following format:
<Security:CheckPoint runat="server">
<Groups>
<asp:ArrayList>
<asp:Int16>1</asp:Int16>
</asp:ArrayList>
</Groups>
<Success>
Hello, world!
</Success>
<Failure>
Goodbye, world!
</Failure>
</Security:CheckPoint>
Groups is a bit clunky; I'll probably change it to a delimited list eventually. At any rate, even if I reduce the CheckPoint class's Render method to:
foreach (Control c in this.Success)
{
c.RenderControl(output)
}
I receive a null reference error. Do non-scalar properties of controls need to be set programatically, e.g. in the page_load event?