Hi there,
I have an issue that I am trying to get my head around.
I have a project and have created a master page after building most of the project.
I think I have a handle on Master Pages and my test page works perfectly.
I have edited the top line of my content page to include the master page.
I have also taken out all HTML or code parts that are not contained within Content Place Holder.
My Master Page only has my menu information in the <asp:ContentPlaceHolder ID="body" runat="server">.
So if I set up a test.aspx file with the following code it works perfectly.
The Web Form was working perfectly until I added the Master Page code.
When I load the page, the master page is loading correctly and my form appears in the content area as it is suppose to. My validation is also working on the form. So all is well with the form.
But when I now add content in the fields and button Add the program not print the values selected in DropDownList.
Can you help me?
<asp:DropDownList ID="ddlFruits" runat="server">
<asp:ListItem Text="Please Select" Value="0" />
<asp:ListItem Text="Mango" Value="1" />
<asp:ListItem Text="Apple" Value="2" />
<asp:ListItem Text="Banana" Value="3" />
<asp:ListItem Text="Orange" Value="4" />
</asp:DropDownList>
<br />
<br />
<asp:Button ID="btnSubmit" Text="Save" runat="server" OnClick="Save" />
<hr />
protected void Save(object sender, EventArgs e)
{
List<string> value1 = new List<string>();
foreach (string item in Request.Form)
{
if (item.StartsWith("ddlFruits_"))
{
value1.Add(Request.Form[item]);
}
}
ClientScript.RegisterStartupScript(this.GetType(), "alert",
"alert('Selected Fruits:\\n" + string.Join(",", value1) + "');", true);
}