Hello
I made a web page that needs the user to insert some info in text boxes and then submit them .
I want to ask about how can i insert as an option to drop down list once i enter the textbox value by the user like this
NAME <input type ="text" id="name"/>
<asp:DropDownList ID="Namelist" runat="server">
<asp:ListItem>new user </asp:ListItem>
<asp:ListItem > the text taken from the textbox </asp:ListItem>
</asp:DropDownList>
NOW , I want to do it using jquery ( info.aspx ) file or in the behind code , i tried to do the behind code in c# but the id of the text box isnt recognizable a syntax error pops up says that its not in the context ..all what i saw while searching was inserting to the drop down list after button click event ...but i dont want this . in the user ( info.aspx.cs) file behind code i tried this
protected void NameList_SelectedIndexChanged(object sender, EventArgs e)
{
NameList.Items.Add( name.Text);
}
but the id of the "name" text box doesnt exist in the current context ,also i tried to add it as an option
NameList.Items.Add(new ListItem (name.Text));
For the date elements this worked
day.InnerText = DateTime.Today.ToString("dddd");//show day in label day
timeDate.InnerText = DateTime.Today.ToString("MM/dd/yyyy");// show date in label time date
but to fill the drop down list it didnt work! any idea how to fill it when the user select from the list's options? thanks