需要以编程方式为 BulletedList 创建点击事件

发布于 2024-12-13 19:05:56 字数 318 浏览 2 评论 0原文

我有以下 BulletedList,其中包含 ListItem。我需要为列表项提供一个 onclick 事件。

所以我的代码:

BulletedList ul = new BulletedList();
ul.ID = "paginationDyn";
ul.DisplayMode = BulletedListDisplayMode.LinkButton;
ul.Click = //What needs to come up here?

我必须在 ul.Click 属性中提供什么?还需要创建 click 方法。

谢谢

I have the following BulletedList with ListItem's in it. I need to give an onclick event to the listitems.

So my code:

BulletedList ul = new BulletedList();
ul.ID = "paginationDyn";
ul.DisplayMode = BulletedListDisplayMode.LinkButton;
ul.Click = //What needs to come up here?

What do I have to give in the ul.Clickproperty? And also click method needs to be created.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

浮生面具三千个 2024-12-20 19:05:57
ul.Click += new BulletedListEventHandler(ul_Click);

然后在代码中的其他位置

void ul_Click(object sender, BulletedListEventArgs e)
    {
        throw new NotImplementedException();
    }

如果您使用的是 Visual Studio,则可以通过键入 += 来自动完成此操作
然后按 Tab 键。

ul.Click += new BulletedListEventHandler(ul_Click);

then else where in your code

void ul_Click(object sender, BulletedListEventArgs e)
    {
        throw new NotImplementedException();
    }

If you are using Visual Studio, you can get auto completeion for this by typing the +=
and then pressing tab.

深白境迁sunset 2024-12-20 19:05:57

我猜你想要的是:

    ...
    BulletedList ul = new BulletedList();
    ul.ID = "paginationDyn";
    ul.DisplayMode = BulletedListDisplayMode.LinkButton;
    ul.Click += new BulletedListEventHandler(ul_Click);
}

void ul_Click(object sender, BulletedListEventArgs e)
{
    throw new NotImplementedException();
}

I guess what you want is:

    ...
    BulletedList ul = new BulletedList();
    ul.ID = "paginationDyn";
    ul.DisplayMode = BulletedListDisplayMode.LinkButton;
    ul.Click += new BulletedListEventHandler(ul_Click);
}

void ul_Click(object sender, BulletedListEventArgs e)
{
    throw new NotImplementedException();
}
溺ぐ爱和你が 2024-12-20 19:05:57

如果您想发起事件此页面说明了如何实施事件你自己的。

如果您只想引发 BulletedList 的内置事件,则需要创建一个调用 OnClick 的子类。

public class MyBulletedList : BulletedList{
    protected void function doStuff(){
        OnClick();
    }
}

这将触发 BulletedList 的单击事件。

If you want to raise an event this page explains how to implement an event of your own.

If you just want to raise the built-in event of the BulletedList you need to create a sub class which calls OnClick.

public class MyBulletedList : BulletedList{
    protected void function doStuff(){
        OnClick();
    }
}

This will fire the click event of the BulletedList.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文