0
<asp:Button ID="btnEditAdd" Text="Edit" 
CausesValidation="false" CommandName="Edit" Visible="false" runat="server" OnCommand="btnEditAdd_Click"/>

How come the above control's got both OnCommand and CommandName attribute? When that button is clicked what method is called ? I don't why I am confused.

I mean the repeater's ItemCommand event is fired or btnEditAdd_Click is called??

I thot they both serve the same purpose.

0

3 Answers 3

2

AFAIK, ItemCommand is a property which helps to identify whether a separate event handler is to be called or the items own event handler is to be called.

Sign up to request clarification or add additional context in comments.

Comments

0

You can debug this yourself by placing breakpoints on both the btnEditAdd_Click event and repater's ItemCommand. If both breakpoints are hit then both events are being called.

Comments

0

The CommandName property is just a string identifier.

The btnEditAdd_Click method will be called, and its e parameter will contain the CommandName.

The repeater's ItemCommand event will also be fired.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.