About controls bound in repeater do not trigger ItemCommand events

Source: Internet
Author: User

Today you encounter a button in repeater, click button and jump to another page.

Html.

1 <Asp:repeaterID= "Repeater"runat= "Server"OnItemCommand= "Repeater_itemcommand">2             <ItemTemplate>3                 <Table>4                     <TR>5                         <TD>Id:<%# Eval("ID") %></TD>6                         <TD>7                             <%--<Asp:imagebutton ID="bnt12"IMAGEURL="~/help.png"runat="Server"CommandName="Jump"/>--%>8                             <Asp:buttonrunat= "Server"Text= "Jump"ID= "Bnt1"CommandName= "Jump" />9                         </TD>Ten                     </TR> One                 </Table> A             </ItemTemplate> -         </Asp:repeater>

Cs.

1        protected voidRepeater_itemcommand (Objectsource, RepeaterCommandEventArgs e)2         {3             if(E.commandname = ="Jump")4             {5Response.Redirect ("http://www.baidu.com");6             }7}

When I click on the button, I find that it won't jump.

On the internet has been looking for a lot of information, and finally found that the probable cause is

  1. When the button is clicked refresh the page repeater again, the ItemCommand refreshed,

2. Use the Dopostback type to jump the page, both LinkButton.

  Workaround: Do not let repeater rebind data or use Dopostback when clicking on the button.

About controls bound in repeater do not trigger ItemCommand events

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.