---
title: "HiddenField.Value is an empty string upon postback inside my custom control"  
description: "HiddenField.Value is an empty string upon postback inside my custom control"  
author: "Samuel Fernandes"  
published: 2014-08-23  
updated: 2014-08-23  
canonical: https://www.mindstick.com/forum/2116/hiddenfield-value-is-an-empty-string-upon-postback-inside-my-custom-control  
category: "asp.net"  
tags: ["asp.net"]  
reading_time: 2 minutes  

---

# HiddenField.Value is an empty string upon postback inside my custom control

I have a [custom](https://www.mindstick.com/blog/12298/use-custom-writing-services-to-get-through-the-finals) [control](https://www.mindstick.com/blog/197/asp-dot-net-repeater-control) that has a hidden field. Upon [postback](https://www.mindstick.com/blog/342/postback-in-asp-dot-net) I want to obtain the value [stored](https://www.mindstick.com/forum/157561/what-is-the-stored-procedure-create-a-procedure-to-find-the-record-by-stu_id-from-the-student-table) in it, but it's always an [empty string](https://www.mindstick.com/forum/12697/json-stringify-is-sending-empty-string). any thoughts?

I am performing [client](https://www.mindstick.com/articles/23198/3-steps-to-ensure-that-your-client-portal-is-impeccable)-side [manipulation](https://www.mindstick.com/blog/63649/77-727-microsoft-excel-2016-core-data-analysis-manipulation-and-presentation-exam) of the hidden field [values](https://www.mindstick.com/forum/327/sum-textbox-values) and have verified in firebug that the [fields](https://www.mindstick.com/forum/159126/sql-query-for-all-tables-and-fields-in-an-oracle-db) are correct before issue a post back

Here is the setup:

```
public class DualListPanel : SWebControl, INamingContainer    {        protected IList<DlpItem> UnassignedList { get; set; }        protected IList<DlpItem> AssignedList { get; set; }        private HiddenField assignedItemsField, unassignedItemsField;        public DualListPanel()        {            CssClass = "DualListPanel";            EnableViewState = true;        }        #region ViewState        protected override void LoadViewState(object savedState)        {            var state = savedState as object[];            UnassignedList =   state[0] as List<DlpItem>;            AssignedList = state[1] as List<DlpItem>;            base.LoadViewState(state[2]);        }        protected override object SaveViewState()        {            object[] state = new object[3];            state[0] = UnassignedList;            state[1] = AssignedList;            state[2] = base.SaveViewState();            return state;        }        #endregion        #region WebControl Overrides        protected override void OnInit(EventArgs e)        {            EnsureChildControls();            GetUnassignedList(); //omitted method            GetAssignedList(); //omitted method            base.OnInit(e);        }        protected override void CreateChildControls()        {                     assignedItemsField = new HiddenField();            assignedItemsField.ID = "HiddenAssignedItems";            assignedItemsField.EnableViewState = true;            unassignedItemsField = new HiddenField();            unassignedItemsField.ID = "HiddenUnassignedItems";            unassignedItemsField.EnableViewState = true;            Controls.Add(assignedItemsField);            Controls.Add(unassignedItemsField);            base.CreateChildControls();        }        #endregion        #region Item Lists Retrieval        public string GetCommaDelimUnassignedItems()        {            return unassignedItemsField.Value;        }        public string GetCommaDelimAssignedItems()        {            return assignedItemsField.Value;        }        #endregion    }
```

## Replies

### Reply by Sumit Kesarwani

Hi Samuel, \
try this:\

```
protected override void CreateChildControls()         {                     
 if(!ispostback){ assignedItemsField =new HiddenField();      assignedItemsField.ID= "HiddenAssignedItems"; assignedItemsField.EnableViewState =true;           unassignedItemsField= new HiddenField();            unassignedItemsField.ID = "HiddenUnassignedItems";
 unassignedItemsField.EnableViewState =true;       Controls.Add(assignedItemsField);              Controls.Add(unassignedItemsField);           base.CreateChildControls();      } }
```


---

Original Source: https://www.mindstick.com/forum/2116/hiddenfield-value-is-an-empty-string-upon-postback-inside-my-custom-control

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
