While developing a custom control I discovered a very important thing related to how all key value pairs in FORM on a page get named and added. I had a hidden input field added to the page. I was only setting ID of the control but was not specifying the name attribute for it. On PostBack i was not getting my field back. May be I was but i did not see any key named as "name" that I specified for the control. Then I set "name" attribute for the control, and I was able to get the value set in that hidden input field back during post back.
HtmlGenericControl selectedObjField = new HtmlGenericControl("input");
selectedObjField .Attributes.Add("type", "hidden");
selectedObjField .Attributes.Add("id", "_selected_cms_list");
selectedObjField .Attributes.Add("name", "_selected_objs_list");
mainPanel.Controls.Add(selectedObjField );
if (this.Page.IsPostBack)
{
string selectedCMs = this.Page.Request["_selected_objs_list"];
if (!string.IsNullOrEmpty(selectedCMs))
{}
}
Set name attribute for HtmlInputHidden or hidden input control
How to set attributes to autoresize width and height of silverlight control/page
How to plan CCSP Exam preparation
Develop a MongoDB pipeline to transform data into time buckets
Alert and Confirm pop up using BootBox in AngularJS
AngularJS Grouped Bar Chart and Line Chart using D3
How to lock and unlock account in Asp.Net Identity provider
2025 © Byteblocks, ALL Rights Reserved. Privacy Policy | Terms of Use