V
vcuankitdotnet
Hi. I have tried to search for this online, but can't find what I'm
looking for so I decided to come here. I have a ASP.NET 2.0 website
with a masterpage. My .aspx page uses the masterpage. Here is the HTML
from my .aspx page:
<asp:Content ID="Content" ContentPlaceHolderID="MyContentArea"
runat="server">
<asplaceHolder ID="phControlHolder" runat="server"></
asplaceHolder><br /><br />
<asp:Button ID="btnSubmitForm" runat="server" Text="Sign Up!"
OnClick="btnSubmitForm_Click" />
</asp:Content>
In my Page_Init method of my .aspx.cs page, I dynamically create a
DropDownList web control and place it inside the phControlHolder
control using:
if (!Page.IsPostback)
{
DropDownList ddl = new DropDownList();
//add items inside the ddl
phControlHolder.Controls.Add(ddl);
}
When the user clicks the btnSubmitForm button, I would like to
retrieve the dropdown that was dynamically created and store the value
the user has picked. I have tried looping through all the controls on
the page, and also looping through all of the controls inside the
PlaceHolderControl, but I haven't been able to retrieve the
dynamically created control.
I feel as though I am losing the control once the page has posted
back, but I don't really know how to address the situation. Any help
would be greatly appreciated! Thanks!
looking for so I decided to come here. I have a ASP.NET 2.0 website
with a masterpage. My .aspx page uses the masterpage. Here is the HTML
from my .aspx page:
<asp:Content ID="Content" ContentPlaceHolderID="MyContentArea"
runat="server">
<asplaceHolder ID="phControlHolder" runat="server"></
asplaceHolder><br /><br />
<asp:Button ID="btnSubmitForm" runat="server" Text="Sign Up!"
OnClick="btnSubmitForm_Click" />
</asp:Content>
In my Page_Init method of my .aspx.cs page, I dynamically create a
DropDownList web control and place it inside the phControlHolder
control using:
if (!Page.IsPostback)
{
DropDownList ddl = new DropDownList();
//add items inside the ddl
phControlHolder.Controls.Add(ddl);
}
When the user clicks the btnSubmitForm button, I would like to
retrieve the dropdown that was dynamically created and store the value
the user has picked. I have tried looping through all the controls on
the page, and also looping through all of the controls inside the
PlaceHolderControl, but I haven't been able to retrieve the
dynamically created control.
I feel as though I am losing the control once the page has posted
back, but I don't really know how to address the situation. Any help
would be greatly appreciated! Thanks!