4

I want to create a hidden html field:

string _ResultHidden = "";

var Detail_Like = MainClass.objFestivalImageLike.FestivalImageLike_List(MD.User_ID);

foreach (var item in Detail_Like)
{

    if (item.Festival_Image_Like_Count == 1)
    {
        _ResultHidden += **@"<asp:HiddenField ID=""hid_" + item.Festival_Image_ID + @""" runat=""server"" Value=""1""></asp:HiddenField>"**;
    }
    else
    {
         _ResultHidden += @"<asp:HiddenField ID=""hid_" + item.Festival_Image_ID + @""" runat=""server"" Value=""0""></asp:HiddenField>";
    }
}

Literal.Text = _ResultHidden;

Now I want access to the hidden field value.

Erik
  • 2,137
  • 3
  • 25
  • 42
Ali Nazari
  • 43
  • 1
  • 5

1 Answers1

4

You can create any control from code behind, and add it to page or panel control. for hidden field you can do like this

Code behind:

  HiddenField hf = new HiddenField();
  hf.ID = "myNEwHF";
  hf.Value = "myValue";
  Panel2.Controls.Add(hf); // or Page.Form.Controls.Add(hf);

Html Markup:

   <asp:Panel ID="Panel2" runat="server">
    </asp:Panel>
Satinder singh
  • 10,100
  • 16
  • 60
  • 102