Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
125
Creating HiddenFields Dynamically.
posted

Hi,

I have a WARP and few controls within it. I am creating HiddenFields dynamically on "click" of a button which is presrnt within the WARP.Code behind which creates the Hidden field is as follows.

public void CreateHiddenVariable(string hiddenVariableName, string hiddenVariableValue)

{

HiddenField hiddenField = new HiddenField();

hiddenField.ID = hiddenVariableName;

hiddenField.Value = hiddenVariableValue;

this.form1.Controls.Add(hiddenField);

}

The hidden field values is to be read in the Client side.

The hiddenField is getting created successfully... .I try fetching the HiddenField at the client side using (on some client side event of a control within WARP)

var hidden = document.getElementById("HIDDENFIELD1")..

the variable hidden always return a null.

This is because the hidden variables created from the server side are not getting rendered at the client side as a partial post back and not a full postback is taking place because of WARP.

Could you please help me to fix this issue is there anyway to render this hiddenField onto the client side ?

I cant change the logic as this implementation is done for a specific reason.

Thanks in Advance..

-Nuthan

Parents
No Data
Reply
  • 4493
    posted

     Hi Nuthan,

    You can also change your code-behind and add the hiddenField to the controls collection of the WARP panel, instead of adding it to the controls collection of the Form control. Thus you will get working code, but be careful: If you awlays set the same ID for the hidden control on your ClickHandler you will get only one Hidden control rendered to the client !

Children
No Data