Reputation: 43
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.
Upvotes: 4
Views: 6385
Reputation: 10198
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>
Upvotes: 4