Infragistics Home

Infragistics Forums

Infragistics community online discussions.
Welcome to Infragistics Forums Sign in | FAQ
in Search

Creating HiddenFields Dynamically.

Last post 08-07-2008 7:22 by [Infragistics] Anton Staykov. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 08-04-2008 7:24

    • Nuthan
    • Not Ranked
    • Joined on 05-29-2008
    • Points 125

    Creating HiddenFields Dynamically.

    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

    • Post Points: 35
  • 08-07-2008 5:47 In reply to

    Re: Creating HiddenFields Dynamically.

    Hello Nuthan,

    I believe I know what is going on - WARP takes care of updating contents only within its tags, so if you create a new hidden and append it to the form, it will not be update upon WARP Refresh Request.

    The solution could be to place

    <igmisc:webasyncrefreshpanel ...

         <asp:hiddenfield runat="server" ID="HiddenField1" ... /> 

    </igmisc> 

    and you can update the internal to WARP hidden and access its value in the RefreshComplete client-side event (fired when WARP finishes its update) 

    Best Regards,
    Rumen Stankov (MCSD.NET)
    The Infragistics ASP.NET Team
    • Post Points: 5
  • 08-07-2008 7:22 In reply to

    Re: Creating HiddenFields Dynamically.

     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 !

    Best Regards,
    Anton Staykov
    The Infragistics ASP.NET Team
    • Post Points: 5
Page 1 of 1 (3 items)
Powered by Community Server (Commercial Edition), by Telligent Systems