ASP.NET Custom Controls
-
I'm creating an ASP.NET custom control that will display several LinkButton derived objects with a separator graphic between them. My problem is that I keep getting the following error message if I attempt to put in any LinkButton derived objects: Type 'Lux.Presentation.LuxControls.LuxLinkItem' in Assembly 'Lux.Presentation.LuxControls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable." I'm not sure why it needs to be serializable. I can't find out any reason for this. So, I added the Serializable attribute and I get almost the same error again, but for the LinkButton class. Since the Microsoft control doesn't need to be serializable, I can't see why mine should need to be. I'm obviously missing some piece of the puzzle. Here is what the code on the ASPX page looks like:
<Lux:LuxLinks ID="LuxLinks1" runat="server" SeparatorImageUrl="~/bullet.gif" Width="100%" >
<Items>
<Lux:LuxLinkItem runat="server" ID="lli1">First Link Button</Lux:LuxLinkItem>
</Items>
</Lux:LuxLinks>Does anyone have any ideas? Is there anything I could try out?
-
I'm creating an ASP.NET custom control that will display several LinkButton derived objects with a separator graphic between them. My problem is that I keep getting the following error message if I attempt to put in any LinkButton derived objects: Type 'Lux.Presentation.LuxControls.LuxLinkItem' in Assembly 'Lux.Presentation.LuxControls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable." I'm not sure why it needs to be serializable. I can't find out any reason for this. So, I added the Serializable attribute and I get almost the same error again, but for the LinkButton class. Since the Microsoft control doesn't need to be serializable, I can't see why mine should need to be. I'm obviously missing some piece of the puzzle. Here is what the code on the ASPX page looks like:
<Lux:LuxLinks ID="LuxLinks1" runat="server" SeparatorImageUrl="~/bullet.gif" Width="100%" >
<Items>
<Lux:LuxLinkItem runat="server" ID="lli1">First Link Button</Lux:LuxLinkItem>
</Items>
</Lux:LuxLinks>Does anyone have any ideas? Is there anything I could try out?
Do you add the controls to the viewstate? An object must be serializable to be saved in viewstate.
-
Do you add the controls to the viewstate? An object must be serializable to be saved in viewstate.
Paddy Boyd wrote:
Do you add the controls to the viewstate? An object must be serializable to be saved in viewstate.
:doh: That makes sense. I've altered my Load and Save Viewstate methods and it works now. I was just dumping the items directly into the viewstate. I though it would automatically call Load/SaveViewstate as needed. Thanks. I've got this working now.