locked
Compilation Error when opening an uploaded Web Form. RRS feed

  • Question

  • User1768953725 posted

    I am using Visual Studio 2017, and working on a simple web page that has a few drop down lists, text boxes and a submit button that sends an email with the information of the web form.

    I was asked to do cascading dropdownlists, and while it works fine in the preview mode, it gives me a compilation error when I upload the project and try to run it from the web server. The error that i'm getting from the web server is:

    Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

    Compiler Error Message: CS1061: 'test_index_aspx' does not contain a definition for 'ddlLocation_SelectedIndexChanged' and no extension method 'ddlLocation_SelectedIndexChanged' accepting a first argument of type 'test_index_aspx' could be found (are you missing a using directive or an assembly reference?)

    Source Error:

    Line 81:                     Location</td>
    Line 82:                 <td>
    Line 83:                     <asp:DropDownList ID="ddlLocation" runat="server" AutoPostBack="True" TabIndex="2" Width="100%" OnSelectedIndexChanged="ddlLocation_SelectedIndexChanged">
    Line 84:                         <asp:ListItem Selected="True" style="display:none">Select One</asp:ListItem>
    Line 85:                         <asp:ListItem>Interior</asp:ListItem>

    Source File: h:\root\home\cooladmin-001\www\cooledge\test\Index.aspx    Line: 83 

    From what i can see, it doesnt look like it is seeing my 'ddlLocation_SelectedIndexChanged' or my 'ddlLocation_SelectedIndexChanged' handling of the value when it is select. The method looks like this in the code behind:

            protected void ddlLocation_SelectedIndexChanged(object sender, EventArgs e)
            {
                switch (ddlLocation.Text)
                {
                    case "Interior":
                        ddlColourTemperatureCCT.Items.Clear();
                        ddlColourTemperatureCCT.Items.Insert(0, new ListItem("Select One", "Select One"));
                        ddlColourTemperatureCCT.Items[0].Selected = true;
                        ddlColourTemperatureCCT.Items.Add(new ListItem("2200K", "2200K"));
                        ddlColourTemperatureCCT.Items.Add(new ListItem("2700K", "2700K"));
                        ddlColourTemperatureCCT.Items.Add(new ListItem("3000K", "3000K"));
                        ddlColourTemperatureCCT.Items.Add(new ListItem("3500K", "3500K"));
                        ddlColourTemperatureCCT.Items.Add(new ListItem("4000K", "4000K"));
                        ddlColourTemperatureCCT.Items.Add(new ListItem("5700K", "5700K"));
                        ddlColourTemperatureCCT.Items.Add(new ListItem("TNW (2700K - 5700K)", "TNW (2700K - 5700K)"));
                        ddlColourTemperatureCCT.Items.Add(new ListItem("DTW (3500K - 2200k)", "DTW (3500K - 2200k)"));
                        ddlColourTemperatureCCT.Items[0].Attributes["disabled"] = "disabled";
    
                        ddlLightOutputRating.Items.Clear();
                        ddlLightOutputRating.Items.Insert(0, new ListItem("Select One", "Select One"));
                        ddlLightOutputRating.Items[0].Selected = true;
                        ddlLightOutputRating.Items.Add(new ListItem("150", "150"));
                        ddlLightOutputRating.Items.Add(new ListItem("300", "300"));
                        ddlLightOutputRating.Items.Add(new ListItem("600", "600"));
                        ddlLightOutputRating.Items.FindByValue("Select One").Attributes.Add("disabled", "disabled");
                        break;
                    case "Exterior":
                        ddlColourTemperatureCCT.Items.Clear();
                        ddlColourTemperatureCCT.Items.Insert(0, new ListItem("Select One", "Select One"));
                        ddlColourTemperatureCCT.Items[0].Selected = true;
                        ddlColourTemperatureCCT.Items.Add(new ListItem("2700K", "2700K"));
                        ddlColourTemperatureCCT.Items.Add(new ListItem("3000K", "3000K"));
                        ddlColourTemperatureCCT.Items.Add(new ListItem("3500K", "3500K"));
                        ddlColourTemperatureCCT.Items.Add(new ListItem("4000K", "4000K"));
                        ddlColourTemperatureCCT.Items.Add(new ListItem("5700K", "5700K"));
                        ddlColourTemperatureCCT.Items.FindByValue("Select One").Attributes.Add("disabled", "disabled");
    
                        ddlLightOutputRating.Items.Clear();
                        ddlLightOutputRating.Items.Insert(0, new ListItem("Select One", "Select One"));
                        ddlLightOutputRating.Items[0].Selected = true;
                        ddlLightOutputRating.Items.Add(new ListItem("300", "300"));
                        ddlLightOutputRating.Items.Add(new ListItem("600", "600"));
                        ddlLightOutputRating.Items.FindByValue("Select One").Attributes.Add("disabled", "disabled");
                        break;
                }
            }

    I am at a loss as to why it cant see it, any ideas?

    Tuesday, September 25, 2018 5:31 PM

All replies

  • User475983607 posted

    If this is a web site, did you deploy the cs file?  If this is a web application, did you deploy the dll located in the bin folder?

    Tuesday, September 25, 2018 5:39 PM
  • User1768953725 posted

    It is a website, i have deployed it two different way with the same results (using the recommended settings from the hosting company)

    1. In VS > Build > Publish WebApplication. And getting it to delete all files and then upload it all
    2. Using an FTP client, i delete all the files and then upload them all (including subfolders)

    Both give me the same errors. It was working fine, until I the the last change which is where the ddlLocation_SelectedIndexChanged was implemented. I have a similar dropdown box that has a similar events happen when a selection is made, but it always worked fine. Only difference is that this one has creates the contents of two dropdown lists, while the other sets the values of two variables.

    Tuesday, September 25, 2018 6:58 PM
  • User475983607 posted

    This error also happens when you've messed with the page directive or copied a web form.  Basically, the markup page cannot find the server control or handler in the code behind.

    Tuesday, September 25, 2018 7:15 PM
  • User1768953725 posted

    I only made changes to two files. I didnt copy the form, all the code is original (ugly at the moment, but fucntional)

    index.aspx
    index.cs

    Where would i find the page directive? i still have copies of old versions of the site so i can compare them to see whats changed.

    Tuesday, September 25, 2018 8:25 PM
  • User475983607 posted

    I only made changes to two files. I didnt copy the form, all the code is original (ugly at the moment, but fucntional)

    index.aspx
    index.cs

    Where would i find the page directive? i still have copies of old versions of the site so i can compare them to see whats changed.

    Keep in mind that error is referencing test_index.  

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

    Tuesday, September 25, 2018 9:20 PM
  • User1768953725 posted

    True, but i also do not have such a file in the project. I searched and couldnt find anything.

    hmmm....  Something just occured to me. This is a test version that i am working on, and in order to not interrupt the live site, i've been working in a separate folder. I'm begining to think that the site is accessing files from the / folder and isnt finding them, thus throws the error.

    But i wont be able to test out this theory until after hours when i can back up the live site and push the new version up, and test out the theory.

    So current build i keep uploading to /test/ i think i might need to add a test domain to do a full test if that is the case.

    Tuesday, September 25, 2018 10:11 PM