J
jand187
Hi,
I'm using ASP.Net 2.0 Beta 2.
I have an aspanel that works as a list. I have a button that adds an
item to that list. When i click on the button I want a new item
(UserControl ASCX) to be added to the list.
But every time i click on the button it seems my list is cleared and
only the newest item is added to the list.
The idea is to start with an empty list and then the user can choose
among several types (ascx) through a normal dropdown and add them to
the list by clicking the "Add" button, but somehow i cannot get my
PanelControl to hold the other controls already added by previous
clicks on the add button.
ASPX:
<form id="form1" runat="server">
<asp:Button runat="server" ID="btn_Add" Text="Add"
OnClick="btn_Add_Click" />
<aspanel ID="pnl_ItemList" runat="server" Height="300px"
Width="400px" style="overflow-y: auto;" />
</form>
CS:
protected void btn_Add_Click( object sender, EventArgs e )
{
UserControl item = (UserControl) LoadControl( "Item.ascx" );
pnl_ItemList.Controls.Add( item );
}
I think i need to do some Viewstate stuff, but the new ASP.Net 2.0
eludes me. It seems like a lot of stuff is hidden (like the
eventhandler setup).
Please let me know if you have an idea.
Thanx in advance.
JanD
I'm using ASP.Net 2.0 Beta 2.
I have an aspanel that works as a list. I have a button that adds an
item to that list. When i click on the button I want a new item
(UserControl ASCX) to be added to the list.
But every time i click on the button it seems my list is cleared and
only the newest item is added to the list.
The idea is to start with an empty list and then the user can choose
among several types (ascx) through a normal dropdown and add them to
the list by clicking the "Add" button, but somehow i cannot get my
PanelControl to hold the other controls already added by previous
clicks on the add button.
ASPX:
<form id="form1" runat="server">
<asp:Button runat="server" ID="btn_Add" Text="Add"
OnClick="btn_Add_Click" />
<aspanel ID="pnl_ItemList" runat="server" Height="300px"
Width="400px" style="overflow-y: auto;" />
</form>
CS:
protected void btn_Add_Click( object sender, EventArgs e )
{
UserControl item = (UserControl) LoadControl( "Item.ascx" );
pnl_ItemList.Controls.Add( item );
}
I think i need to do some Viewstate stuff, but the new ASP.Net 2.0
eludes me. It seems like a lot of stuff is hidden (like the
eventhandler setup).
Please let me know if you have an idea.
Thanx in advance.
JanD