troubleshooting Question

Error on linkbutton click

Avatar of Peter Nordberg
Peter NordbergFlag for Sweden asked on
.NET ProgrammingASP.NET
10 Comments2 Solutions1003 ViewsLast Modified:

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.

Serves the Most High - Not Religion

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 10 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 10 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros