I am using jQuery FaceBox to show a text box, a dropdown and a button. The user can write text in a text field, select a value in ddl abd, click a button. This calls the code in code. FaceBox looks great, and the content in it is also in order. In addition, a button event is fired. This is the code for the button event handler:
protected void Button1_Click(object sender, EventArgs e) { _favorit = new Favoritter(); ListItem fav = ddl_favoritter.SelectedItem; _favorit.FavoritterFolderID = int.Parse(fav.Value);
A business object is created, and its properties are set with the values โโread from the controls. Then the object is inserted into the database, which works fine. The problem is that the values โโof the text box and the drop-down menu are not set properly. The text box value is empty, and the selected ddl value is always 1, even if I write in the text box and select another ddlitem before I click the button. Ddl loads as follows:
if (!Page.IsPostBack) { _favoritter = FavoritterFolderManager.GetFavoritterFolderByUser(UserID); ddl_favoritter.DataSource = _favoritter; ddl_favoritter.DataBind(); }
I tried to put this code outside the if (! Page.IsPostBack), and also populate it with objectdatasource, still the same problem. This is similar to the โresetโ controls when I press the button, and I don't think it has anything to do with FaceBox, since all it does is show a div containing the controls ... Then, it can ... any ideas?
This is the code on the aspx page:
<div id="showme" style="display:none;"> Add to favourites.<br /> <br /> <p> Title: <span><asp:TextBox ID="txt_favoritNavn" runat="server"></asp:TextBox></span></p> <p> select folder: <span><asp:DropDownList ID="ddl_favoritter" runat="server" DataTextField="FavoritterFolderNavn" DataValueField="FavoritterFolderID" AppendDataBoundItems="true"> </asp:DropDownList> </span> </p> <br /> <asp:Button ID="Button1" runat="server" Text="Gem" onclick="Button1_Click"/> </div>
source share