[thelist] ASP.NET Adding a linkbutton programmatically
Chris Marsh
thelist at cjmarsh.com
Mon Aug 7 16:36:16 CDT 2006
Casey
The following is how I would go about this in C#. It's totally untested as I
don't have VS handy, but it illustrates the use of the Command event rather
than the Click event. The Command event allows you to specify a name for the
command, and an argument which you can then access from your event handler.
I've included a sample event handler below (AlphaCommand).
----------------------------------
for (int i = 65, i <= 90; ++i)
{
LinkButton lb = new LinkButton();
lb.Text = "&#" + i + "; ";
lb.CommandName = "alpha";
lb.CommandArgument = i;
lb.Command += new CommandEventHandler(AlphaCommand);
plhAlpha.Controls.Add(lb);
}
----------------------------------
private void AlphaCommand(object sender, CommandEventArgs e)
{
Response.Output.Write("Command {0} has argument {1}.", e.CommandName,
e.CommandArgument);
}
----------------------------------
You may find the following links useful, they include samples in VB .NET:
<http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.commande
venthandler.aspx>
<http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.linkbutt
on.command.aspx>
HTH
--
Regards
Chris Marsh
> -----Original Message-----
> From: thelist-bounces at lists.evolt.org
> [mailto:thelist-bounces at lists.evolt.org] On Behalf Of Casey Crookston
> Sent: 07 August 2006 21:46
> To: thelist at lists.evolt.org
> Subject: Re: [thelist] ASP.NET Adding a linkbutton programmatically
>
>
> >> You should just assign the listbox ... <<
>
> Tab, a listbox is not what we need. We just want:
>
> A B C D E F G H I J K L M N.....
>
> On the screen as simple text links. Think paging, only with letters.
>
> Thanks!
>
> Casey
>
>
> --
>
> * * Please support the community that supports you. * *
> http://evolt.org/help_support_evolt/
>
> For unsubscribe and other options, including the Tip Harvester
> and archives of thelist go to: http://lists.evolt.org
> Workers of the Web, evolt !
>
> --
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.1.405 / Virus Database: 268.10.7/411 - Release
> Date: 07/08/2006
>
>
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.10.7/411 - Release Date: 07/08/2006
More information about the thelist
mailing list