locked
Unable to cast object of type 'System.EventArgs' to type 'System.Web.UI.WebControls.CommandEventArgs' RRS feed

  • Question

  • Server Error in '/CTD_Development' Application.
    Unable to cast object of type 'System.EventArgs' to type 'System.Web.UI.WebControls.CommandEventArgs'.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.InvalidCastException: Unable to cast object of type 'System.EventArgs' to type 'System.Web.UI.WebControls.CommandEventArgs'.

    Source Error:

    Line 59: </asp:TableCell>
    Line 60: <asp:TableCell ID="tblViews_Cell3" BorderColor="#993399" BorderWidth="2">
    Line 61: <asp:Button ID="ButtonAllOpenTesting" runat="server" CommandArgument=3 OnClick="testclick" Text="All Open Testing" BorderStyle="None" Font-Bold="True" />
    Line 62: </asp:TableCell>
    Line 63: <asp:TableCell ID="tblViews_Cell4" BorderColor="#993399" BorderWidth="2">


    Source File: C:\Documents and Settings\bwferderer\My Documents\Visual Studio 2005\WebSites\CTD_Development\open_contracts.aspx Line: 61

    Stack Trace:

    [InvalidCastException: Unable to cast object of type 'System.EventArgs' to type 'System.Web.UI.WebControls.CommandEventArgs'.]
    ASP.open_contracts_aspx._Lambda$__3(Object a0, EventArgs a1) in C:\Documents and Settings\bwferderer\My Documents\Visual Studio 2005\WebSites\CTD_Development\open_contracts.aspx:61
    System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
    System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
    System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
    System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
    System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565


    Version Information: Microsoft .NET Framework Version:2.0.50727.3082; ASP.NET Version:2.0.50727.3082
    This is the error to my onclick even of a button trying to pass and argument to my procedure call.
    Line 61 shows the button code.

    Here is the code for "testclick" procedure on my aspx.vb page.
    Protected Sub testclick(ByVal Sender As Object, ByVal E As CommandEventArgs)
            'Set all views to non-active color
            DefColors()
    
            'Set requested view to active color 
            Select Case E.CommandArgument
                Case Is = 1
                    Me.tblViews_Cell1.BackColor = Drawing.Color.DarkMagenta
                    Me.ButtonMyTestingAssignments.BackColor = Drawing.Color.DarkMagenta
                    Me.ButtonMyTestingAssignments.ForeColor = Drawing.Color.White
                Case Is = 2
                    Me.tblViews_Cell2.BackColor = Drawing.Color.DarkMagenta
                    Me.ButtonAllOpenTesting.BackColor = Drawing.Color.DarkMagenta
                    Me.ButtonAllOpenTesting.ForeColor = Drawing.Color.White
                Case Is = 3
                    Me.tblViews_Cell3.BackColor = Drawing.Color.DarkMagenta
                    Me.ButtonMyQAAssignments.BackColor = Drawing.Color.DarkMagenta
                    Me.ButtonMyQAAssignments.ForeColor = Drawing.Color.White
                Case Is = 4
                    Me.tblViews_Cell4.BackColor = Drawing.Color.DarkMagenta
                    Me.ButtonAllopenQAAssignments.BackColor = Drawing.Color.DarkMagenta
                    Me.ButtonAllopenQAAssignments.ForeColor = Drawing.Color.White
            End Select
    
        End Sub
    Please help me understand and correct this.
    • Moved by Ji.Zhou Monday, December 7, 2009 7:02 AM ASP.NET issues (From:Visual Basic IDE)
    Tuesday, December 1, 2009 9:27 PM

All replies