Martin
Martin

Reputation: 400

does not contain a definition for 'Y' and no extension method 'Y' accepting a first argument of type 'X' could be found

My newTransport.aspx button control

<asp:Button ID="najitRidiceButton" runat="server" Text="Vyhledat ridice" onclick="najitRidiceButton_Click" />

My newTransport.aspx.cs method

protected void najitRidiceButton_Click(object sender, EventArgs e)
{
    DAODriver.searchDrivers(Calendar1.SelectedDate, casPrepravyTextBox.Text, Int32.Parse(pocetOsobTextBox.Text), extraZavazadla());
}

Error i get

CS1061: ASP.newtransport_aspx does not contain a definition for najitRidiceButton_Click and no extension method najitRidiceButton_Click accepting a first argument of type ASP.newtransport_aspx could be found (are you missing a using directive or an assembly reference?)

when i delete that button, everything works correctly, so i don´t understand it, this is my first ASP.NET web app so please help me i have no idea why it doesn´t work, although i tried to google it or find answer here on stackoverflow - no result

<%@ Page Title="" Language="C#" MasterPageFile="~/PageTemplate.Master" 
AutoEventWireup="true" CodeBehind="NewTransport.aspx.cs" 
Inherits="ASPDU1.NewTransport" %>

Upvotes: 1

Views: 22188

Answers (3)

MHR Navazani
MHR Navazani

Reputation: 13

you seem to be using the ASP.NET WebApplication (i.e., not the ASP.NET WebSite) project type. If so, it is necessary to:

  • Build the application and make sure that the build is successful;
  • Re-deploy the required page/code/designer (or better a complete project) with the just built APPLICATION_NAME.DLL file onto the destination hosting server directory.

Upvotes: 1

ThoBa
ThoBa

Reputation: 515

I have had great success with changing build configuration (e.g. from debug to release), run the project, and then change back to the previous build configuration.

Upvotes: 1

Brian Mains
Brian Mains

Reputation: 50728

Try by making the event handler public void instead of protected, just to see. It works for me as protected void, but there maybe something here that I can't figure out from this sample. I assume that the code-behind is pointed to the correct page in the ASPX markup's @Page reference.

Upvotes: 5

Related Questions