Recently, I designed a custom User Control in asp.net.
public class InputMask : CompositeControl, IPostBackDataHandler, IPostBackEventHandler
Imagine the custom control is enclosed within a div element:
<div runat="server" id="inputArea">
<asp:MaskInput runat="server" ID="ssn" ToolTip="SSN" Format="SSN" PartialMask="true" />
</div>
In the code behind, there is the following snippet:
inputArea.Visible = False
During postback,
LoadPostData(string postDataKey, NameValueCollection postCollection)
does not contain the MaskInput key.
However, if you try this approach:
inputArea.Attributes.Add("style", "display:none")
The postCollection will have the MaskInput key present.
It seems that when using CSS to hide the div, the control is still rendered but invisible. On the other hand, with visible=false, the control is not even rendered at all.
Is there any workaround to retrieve the key in LoadPostData while using visible=false?