mercredi 15 juin 2016

LoadPostData NameValueCollection does not include all controls on postback

I have created an asp.net custom User Control

public class InputMask : CompositeControl, IPostBackDataHandler, IPostBackEventHandler

if for instance, the custom control is within a div

<div runat="server" id="inputArea>
    <asp:MaskInput runat="server" ID="ssn" ToolTip="SSN" Format="SSN" PartialMask="true" />
</div>

and in code behind I have this:

 inputArea.Visible = False

On postback LoadPostData(string postDataKey, NameValueCollection postCollection)postCollection does not have the MaskInput key.

if I do this:

inputArea.Attributes.Add("style", "display:none")

postCollection contains the MaskInput key.

I understand when using css to hide the div, the control is rendered but not displayed. Whereas, when using visible=false, the controls is not rendered at all.

So, is there a workaround to getting the key in LoadPostData when using visible=false?

Aucun commentaire:

Enregistrer un commentaire