简体   繁体   中英

Linkbutton OnCommand not firing after upgrading to .Net 4

I have a webforms project that was written in ASP.Net 3.5 and works fine. I decided to upgrade it to 4.0 for various reasons. The upgrade went fine. However, on one particular page, I have certain linkbuttons that fire an event in code behind. The event never fires on click. Other controls on the page, like an link button with client side code and Telerik radgrid work fine.

This Works

<asp:LinkButton ID="InsertLinkButton" runat="server">
<asp:Image ID="ImageButton1" runat="server" />Add New Employee</asp:LinkButton>
//Code behind adding javascript event
InsertLinkButton.Attributes["onclick"] = String.Format("return ShowInsertForm();");

This Doesn't

<asp:LinkButton ID="ALinkButton" runat="server" CommandName="A" OnCommand="LinkButton_Command" ">A</asp:LinkButton>

The page is a content page with a master page. Any ideas?

I'm not sure if this is just a typo on your post but your markup isn't correct on the LinkButton.

It is currently:

<asp:LinkButton ID="ALinkButton" runat="server" 
    CommandName="A" OnCommand="LinkButton_Command" ">A</asp:LinkButton>

It should be:

<asp:LinkButton ID="ALinkButton" runat="server"
    CommandName="A" OnCommand="LinkButton_Command">A</asp:LinkButton>

The panel containing the controls was referenced as an updated control in a Telerik RadAjaxManager buried in the mark up. If I removed the RadAjaxManager, it worked. Apparently the linkbutton command event didn't fire the ajax callback. Since this worked in 3.5, I'm wondering if some metadata didn't get converted properly during the 3.5>4 upgrade?

Anyway, I updated the references of what was supposed to fire an ajax call from the RadAjaxManager and it now works. Thanks for the help!

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