单一事件处理程序在ASP.NET多个链接/按钮 [英] Single event handler for multiple links/buttons on ASP.NET

查看:108
本文介绍了单一事件处理程序在ASP.NET多个链接/按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含名称的集合的下拉列表。我的整个名称列表是非常大(超过2000),所以我想对下的下拉列表中那些开始以相同字母的名字。

I have a dropdown list that contains a collection of names. My entire names list is very large (over 2,000) so I would like to pair down the names in the drop down list to those starting with the same letter.

要做到这一点,我想有26所有链接在同一行,一个字母表中的每个字母。

To do this I would like to have 26 links all on the same line, one for each letter in the alphabet ..

A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z

的想法是,在信他们有兴趣,而且获得的名称的列表中的存储过程的用户点击重新执行以仅抓住那些以字母名称被点击,并且然后将所得的数据集是反弹到下拉列表中。

The idea being that the user clicks on the letter they are interested in and the stored procedure that obtains the list of names is re-executed to only grab those names starting with the letter that was clicked and then the resulting dataset is rebound to the dropdown list.

什么是伤脑筋我是如何处理创建所有点击事件要处理的链接上的用户点击。 我可以创建26个不同的事件处理程序,每一个环节,但是我不得不相信这是我没有看到一个更简单的方法

What is vexing me is how to handle creating all the "Click Events" necessary to deal with the user "clicking" on a link. I could create 26 different event handlers, one for each link, but I have to believe there is a simpler way I am not seeing.

示范表格是一个链路,信click事件A...

Form demonstration here is the click event for one link, the letter "A" ...

      Protected Sub lnkLetterA_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lnkLeterA.Click
        Call LoadNamesIntoDropDown("A")
      End Sub

有没有一种方法来创建一个事件处理程序,可以处理所有26链接?谢谢你。

Is there a way to create one event handler that could handle all 26 links? Thank you.

P.S。 C#或VB.NET的例子是罚款。我只是碰巧在这种情况下使用VB.NET。

P.S. C# or VB.NET examples are fine. I just happen to be using VB.NET in this case.

推荐答案

您可以重复使用相同click处理一个简单的例子

You can reuse the same click handler a simple example

protected void HandleLinkClick(object sender, EventArgs e)
{
    HyperLink link = (HyperLink)sender;
    LoadNamesIntoDropDown(link.Text);
}

然而,也有自动填充式的解决方案可以使用负载。从MS一次免费
http://www.asp.net/ajax/ajaxcontroltoolkit/samples/autocomplete/autocomplete.aspx

这篇关于单一事件处理程序在ASP.NET多个链接/按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆