更改中继器中链接按钮的文本

发布于 2024-08-12 02:07:12 字数 410 浏览 2 评论 0原文

我有一个中继器,可以显示与帖子相关的评论。

我想添加一些功能,当用户单击链接时,它会从:

报告此帖子

帖子已被标记

我如何访问特定的 lnkBut​​ton?显然,在 ItemDataBound 中,这很容易完成,但在 click 方法中,我不确定如何做到这一点。

我是否需要做类似的事情:

我尝试过这样的事情;

LinkButton lb = repeater.FindControl(LINK_BUTTON_UNIQUE_ID) as LinkButton;
lb.Text = "blah blah blah";

但 lb 始终为空。

任何帮助将不胜感激,谢谢!

I have a repeater which displays comments related to a post.

I want to add some functionality where when the user click on the link it goes from:

report this post

to

post has been flagged

how do I access the specific lnkButton? Obviously in ItemDataBound this is easily done, but in the click method I'm not sure how I would do it.

Do I need to do something like:

I tried something like this;

LinkButton lb = repeater.FindControl(LINK_BUTTON_UNIQUE_ID) as LinkButton;
lb.Text = "blah blah blah";

but lb is always null.

Any help would be appreciated, thanks!

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

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

发布评论

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

评论(1

空‖城人不在 2024-08-19 02:07:12

使用点击处理程序的源参数?

protected void MyLinkButton_OnClick(object sender, EventArgs e)
{
    LinkButton b = sender as LinkButton;
    b.Text = "Some Text";
}

Use the source parameter of the click handler?

protected void MyLinkButton_OnClick(object sender, EventArgs e)
{
    LinkButton b = sender as LinkButton;
    b.Text = "Some Text";
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文