S
Steve Harclerode
Here's some code that I'm using to create a simple list of logical drive
letters (my web application impersonates a user). I'm finding that my event
handler doesn't fire. Can anyone give me a hint as to why it doesn't work?
It's nearly a copy of some sample code that I lifted from a friend, whose
code works (so he says!). By the way, I'm using a dotnet Table control in
the ASPX page which starts off empty, it's ID is dirTable.
By the way, I have a co-worker who had the same issue a year ago, and he
ended up associating client side JavaScript which set a hidden field, and
then called submit().
----------------------
private void Page_Load(object sender, System.EventArgs e)
{
if ( !IsPostBack )
{
SetupDriveList();
}
}
void SetupDriveList()
{
string[] drives = Directory.GetLogicalDrives();
for (int i = 0; i < drives.Length; i++)
{
if ( drives[0] == 'A' || drives[0] == 'B' )
{
continue;
}
TableRow tr = new TableRow();
// create link button for drive letter
LinkButton lb = new LinkButton();
lb.Text = drives;
lb.CommandName = "drive";
lb.CommandArgument = drives[0].ToString();
lb.Command += new CommandEventHandler( OnClickLink );
lb.Attributes.Add("onclick", "OnClickLink" );
// add link button to table cell
TableCell td = new TableCell();
td.Controls.Add( lb );
// add table cell to table row
tr.Cells.Add( td );
// add table row to table
dirTable.Rows.Add( tr );
}
}
void OnClickLink(object O, CommandEventArgs e)
{
string commandName = e.CommandName.ToString();
string commandArg = e.CommandArgument.ToString();
}
letters (my web application impersonates a user). I'm finding that my event
handler doesn't fire. Can anyone give me a hint as to why it doesn't work?
It's nearly a copy of some sample code that I lifted from a friend, whose
code works (so he says!). By the way, I'm using a dotnet Table control in
the ASPX page which starts off empty, it's ID is dirTable.
By the way, I have a co-worker who had the same issue a year ago, and he
ended up associating client side JavaScript which set a hidden field, and
then called submit().
----------------------
private void Page_Load(object sender, System.EventArgs e)
{
if ( !IsPostBack )
{
SetupDriveList();
}
}
void SetupDriveList()
{
string[] drives = Directory.GetLogicalDrives();
for (int i = 0; i < drives.Length; i++)
{
if ( drives[0] == 'A' || drives[0] == 'B' )
{
continue;
}
TableRow tr = new TableRow();
// create link button for drive letter
LinkButton lb = new LinkButton();
lb.Text = drives;
lb.CommandName = "drive";
lb.CommandArgument = drives[0].ToString();
lb.Command += new CommandEventHandler( OnClickLink );
lb.Attributes.Add("onclick", "OnClickLink" );
// add link button to table cell
TableCell td = new TableCell();
td.Controls.Add( lb );
// add table cell to table row
tr.Cells.Add( td );
// add table row to table
dirTable.Rows.Add( tr );
}
}
void OnClickLink(object O, CommandEventArgs e)
{
string commandName = e.CommandName.ToString();
string commandArg = e.CommandArgument.ToString();
}