I am trying to post values from an AjaxToolKit ComboBox using ASP.NET 4.0.
Here is my code:
WebForm1
HTML
<body>
<ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</ajaxToolkit:ToolkitScriptManager>
<div>
<ajaxToolkit:ComboBox ID="ComboBox1" runat="server">
</ajaxToolkit:ComboBox>
<asp:Button ID="Button1" runat="server" Text="Button" UseSubmitBehavior="true" PostBackUrl="~/WebForm2.aspx" />
</div>
</body>
C#
protected void Page_Load(object sender, EventArgs e)
{
for (int i = 0; i < 5; i++)
{
ListItem tmpListItem = new ListItem("Item " + i.ToString());
tmpListItem.Value = "Item " + i.ToString();
ComboBox1.Items.Add(tmpListItem);
}
}
WebForm2
C#
protected void Page_Load(object sender, EventArgs e)
{
HttpContext tmpHttpContext = HttpContext.Current;
string cmboBoxValue = tmpHttpContext.Request["ComboBox1"];
}
All I get for cmboBoxValue is null.
I am so frusterated because I know this must be simple. I am sure I have done this 100* in the past.
I looked here
How to submit http form using C#
but that did not help. It has to be submitted with the asp:Button.
Hopefully this is enough information for you to provide a response.
Thank you for your time.