简体   繁体   中英

Change text of a linkbutton in a repeater

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!

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";
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM