P
ProgrammerChicago
I'm not sure if this is the result of the postback behavior or my own
code, but for some reason my onclick function is not detecting listbox
selections (It's meant to delete files uploaded to the server).
The RemoveFiles function is being executed, bu I have a feeling the
selections are being cleared beforehand.
There is a Page_Load function which repopulates the listbox. Could
this be getting in the way?
Here is the PageLoad...
void Page_Load(Object S, EventArgs E)
{
ListFiles();
}
And basically, here is my listbox:
<asp:ListBox ID="FB" Width="100%" SelectionMode="Multiple""
runat="server" Font-Size="Small" Rows="5" />
My button:
<asp:button OnClick="RemoveFiles" ID="RemoveButton" runat="server"
Text="Remove File(s)" />
Here is the function which is not seeing the item selections:
void RemoveFiles(object sender, EventArgs e)
{
int i = 0;
String filename = "";
for (i = 0; i < (FB.Items.Count); i++)
{
if (FB.Items.Selected) // FB is the
{ // never gets here...
filename = FB.Items.Text.ToString();
System.IO.File.Delete(Session["FilePath"] + "\\" +
filename);
}
}
}
Thanks...
code, but for some reason my onclick function is not detecting listbox
selections (It's meant to delete files uploaded to the server).
The RemoveFiles function is being executed, bu I have a feeling the
selections are being cleared beforehand.
There is a Page_Load function which repopulates the listbox. Could
this be getting in the way?
Here is the PageLoad...
void Page_Load(Object S, EventArgs E)
{
ListFiles();
}
And basically, here is my listbox:
<asp:ListBox ID="FB" Width="100%" SelectionMode="Multiple""
runat="server" Font-Size="Small" Rows="5" />
My button:
<asp:button OnClick="RemoveFiles" ID="RemoveButton" runat="server"
Text="Remove File(s)" />
Here is the function which is not seeing the item selections:
void RemoveFiles(object sender, EventArgs e)
{
int i = 0;
String filename = "";
for (i = 0; i < (FB.Items.Count); i++)
{
if (FB.Items.Selected) // FB is the
{ // never gets here...
filename = FB.Items.Text.ToString();
System.IO.File.Delete(Session["FilePath"] + "\\" +
filename);
}
}
}
Thanks...