Click here to Skip to main content
15,940,550 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
MY PROBLEM
Server Error in '/' Application.
Compilation Error
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: 'ASP.cusinfo_aspx' does not contain a definition for 'TextBoxCustomerNo_TextChanged' and no extension method 'TextBoxCustomerNo_TextChanged' accepting a first argument of type 'ASP.cusinfo_aspx' could be found (are you missing a using directive or an assembly reference?)

Source Error:
Line 56:                   Line 57:                       Line 58:                           <asp:textbox id="TextBoxCustomerNo" runat="server" ontextchanged="TextBoxCustomerNo_TextChanged" autopostback="True" cssclass="form-control" width="400px">
Line 59:                       Line 60:                        Source File: g:\pleskvhosts\mccis.online\httpdocs\Cusinfo.aspx    Line: 58


END OF PROBLEM------

DETAILS:

I have a page name Cusinfo.aspx, with textbox name TextBoxCustomerNo.Text
in my local machine, its working perfect but when I uploaded to my domain, error occured.

My code behind on TextChanged:

C#
protected void TextBoxCustomerNo_TextChanged(object sender, EventArgs e)
        {
            //Search for the Customer from database

            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
            con.Open();
            SqlCommand com = new SqlCommand("Select * from CustomerData Where CISno= '" + TextBoxCustomerNo.Text + "'", con);
            //SqlDataAdapter da = new SqlDataAdapter(com);
            SqlDataReader dr = com.ExecuteReader();



            if (dr.Read())
            {

                TxtFName.Text = (dr["Fname"].ToString());
                TxtLName.Text = (dr["Lname"].ToString());
                DropDwnCategory.SelectedItem.Text = (dr["Category"].ToString());
                DropDwnIDtype.SelectedItem.Text = (dr["IDtype"].ToString());
                TxtIDNo.Text = (dr["IDno"].ToString());
                //check if date is not null
                var dbirt = DateTime.Parse(dr["Dbirth"].ToString());
                if (dbirt != null)
                {
                    TxtDbirth.Text = dbirt.ToString("yyyy-MM-dd");
                }
                TxtPbirth.Text = (dr["Pbirth"].ToString());
                TxtAddress.Text = (dr["Addr"].ToString());
                TxtCity.Text = (dr["City"].ToString());
                DropDwnNationality.SelectedItem.Text = (dr["Nationality"].ToString());

                TxtContact.Text = (dr["Contactno"].ToString());
                DropDwnSrcIncome.SelectedItem.Text = (dr["Sourceoffund"].ToString());
                DropDwnWork.SelectedItem.Text = (dr["Natureofwork"].ToString());

                HyperLink1.NavigateUrl = "~/Tomerphoto.aspx?CISno=" + TextBoxCustomerNo.Text;

                DropDownSex.SelectedItem.Text = dr["Gender"].ToString();
                TxtEmail.Text = dr["Email"].ToString();

                TxtEmployer.Text = (dr["Employer"].ToString());
                TxtPostalCode.Text = dr["Postalcode"].ToString();
                DropDwnCountry.SelectedItem.Text = dr["Country"].ToString();


                var dex = DateTime.Parse(dr["Idexpireon"].ToString());

                ExpiryDate.Text = dex.ToString("dd/MM/yyyy");
                if (ExpiryDate.Text == "01/01/1900")

                {
                    CheckIDNoExpire.Checked = true;
                    ExpiryDate.Visible = false;
                }
                else
                {
                    ExpiryDate.Text = dex.ToString("yyyy-MM-dd");
                }
                txtComment.Text = dr["Comment"].ToString();

                con.Close();
                BtnUpdate.Visible = true;
                BtnSave.Visible = false;

            }
        }


What I have tried:

I dont know what to do, because in my local machine its working, but when I run in my domain error occure.
Posted
Updated 28-Aug-19 0:40am
v5
Comments
Maciej Los 28-Aug-19 3:47am    
Why do you call ToString() method when you operate on datetime variable?
Darwin Ahmed 28-Aug-19 5:15am    
the error is on TextBoxCustomerNo not on datetime variable.
Maciej Los 28-Aug-19 5:17am    
I know. But i wonder why are you calling ToString() method. Don't you think it is redundant?
Darwin Ahmed 28-Aug-19 5:39am    
yes you are right, i used that because my database i used has already data but the dbirth column is null, for your info also, im beginner in asp.net, if you have suggestion please post it here, and i really appreciate it. :)
Maciej Los 28-Aug-19 6:40am    
Done! See, solution #2.

I guess your compiled version dlls are not updated in the deployed location

Try Clean & Rebulid and redeploy

You can also try debugging your deployed code by attaching debugger to the process

Run the website in a browser, then go to the Debug menu in Visual Studio and choose Attach To Process.
It'll show a dialog window with processes listed, tick Show processes from all users and then locate the w3wp.exe process in the list, now click the Attach button.

Attach to Running Processes with the Debugger - Visual Studio 2015 | Microsoft Docs[^]

Now when you generate events and have their handlers break pointed on the server-side, the debugger will stop at the breakpoints in Visual Studio.

I would suggest you to read this article as well
Build solution vs. Rebuild solution vs. Clean solution Menu[^]
 
Share this answer
 
v3
Comments
Darwin Ahmed 28-Aug-19 3:51am    
can not locate the w3wp.exe sir, what will i select?
dnxit 28-Aug-19 4:06am    
Host your application on your local IIS on your machine then start the IIS manager then click on Refresh button on Attach to Process dialog.

Here is an article if you don't know how to host in local IIS
https://www.codeproject.com/Articles/667694/How-to-Host-a-Website-in-IIS7-2
Darwin Ahmed 28-Aug-19 5:02am    
done hosting in local IIS, what to do next?
dnxit 28-Aug-19 5:15am    
One more thing can you try to make
protected void TextBoxCustomerNo_TextChanged(object sender, EventArgs e)
to
public void TextBoxCustomerNo_TextChanged(object sender, EventArgs e)
Darwin Ahmed 28-Aug-19 5:47am    
i tried but same error occured.
At the first look i see few (minor) mistakes to correct:

  1. your code is SQL Injection[^] vulnerable.
    You should use parameterized queries and stored procedures instead of "string-concatenated-commands"! See: SQL Injection and how to avoid it – ASP.NET Debugging[^]
  2. using ToString() method might be the reason of several problems, especially when you want to work on specific type of object (i.e.: datetime)! See: Casting and type conversions - C# Programming Guide | Microsoft Docs[^]
    So, instead of:
    C#
    //#1
    TxtFName.Text = (dr["Fname"].ToString());
    //#2
    var dex = DateTime.Parse(dr["Idexpireon"].ToString());

    use
    C#
    //#1
    TxtFName.Text = (string)dr["Fname"];
    //#2
    if(DBNull.Value.Equals(dr["Idexpireon"]))
        dex = new DateTime(1900,1,1); //set default date
    else
        dex = (DateTime)dr["Idexpireon"]; //grab existing date
    ExpiryDate.Text = dex.ToString("yyyy-MM-dd");

    For further details, please see: DBNull.Value Field (System) | Microsoft Docs[^]
  3. i'd suggest to use using statement[^], because "The using statement calls the Dispose method on the object in the correct way, and (when you use it as shown earlier) it also causes the object itself to go out of scope as soon as Dispose is called."
    C#
    using(SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
        using(SqlCommand com = new SqlCommand("theNameOfStoredProcedureHere", con))
        {
            con.Open();
            com.Parameters.Add(new SqlParameter("@CISno", SqlDbType.Int) {Direction=ParameterDirection.Input, Value=TextBoxCustomerNo.Text}) //add corresponding parameter
            using(SqlDataReader dr = com.ExecuteReader())
            {
                //your code here...
            }

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900