We help IT Professionals succeed at work.
Get Started

Error on linkbutton click

Last Modified: 2013-11-26

I have this usercontrol where I have a linkbutton that I want to handle some code behind when I click on it. The usercontrol is a part of a datalist control. Unfortunately I get an error when I click it:
Unable to cast object of type 'System.EventArgs' to type 'System.Web.UI.ImageClickEventArgs'.
If I use an imagebutton instead it all works fine.

This is my usercontrol code:
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="buyLink.ascx.vb" Inherits="UserControls_Webshop_buy" %>

<asp:HiddenField ID="productID" runat="server" />
<asp:LinkButton ID="btnBuy" runat="server" Width="58px" CssClass="btnBuy" OnClick="NewButton_Click" CommandArgument='<%# Eval("productID") %>'>Köp</asp:LinkButton>
<%--<asp:ImageButton ID="btnBuy" runat="server" CssClass="btnBuy" OnClick="NewButton_Click" CommandArgument='<%#Eval("productID") %>' />--%>
<telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">
        <telerik:AjaxSetting AjaxControlID="btnBuy">
                <telerik:AjaxUpdatedControl ControlID="lblShopCartPrice" />
                <telerik:AjaxUpdatedControl ControlID="PanelCheckout" />
and this is my code behind:
Sub NewButton_Click()
        If Request.Cookies("orderID") Is Nothing Then
            Dim i As New orderDBL

            Response.Cookies("orderID").Value = i.orderID
            Response.Cookies("orderID").Expires = DateTime.Now.AddSeconds(600)




        End If
    End Sub

I would like to use the linkbutton instead of the imagebutton but I'm not sure how I can fix this error.

Watch Question
Serves the Most High - Not Religion
This problem has been solved!
Unlock 2 Answers and 10 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE