-3

I am a newbie to asp.net. I recently publish an asps site from Visual Studio using C#, but I realised that the scripts I wrote for the buttons, links, etc to interact with my database on local machine is missing when I publish the pages.

Do I have to rewrite the code for the pages now on the web host?

Your advice is needed.

Thanks

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Dean
  • 37
  • 3

2 Answers2

0

I think this will answer your question. It's a setting on a file level, available on properties (F5) for the file:

Visual Studio 2010 Web Publish missing a file

Once you set it and republish, the file will show up in the publish location.

Ctznkane525
  • 7,297
  • 3
  • 16
  • 40
0

It's really hard to answer such a question, no details, no code, and things disappearing mysteriously. However, given that you're newbie and from the description that you have, I will try to give you some tips that will hopefully set you in the right direction.

Firstly, I don't know exactly what you mean by "script", so I will assume you're referring to what is called code-behind. ASP.Net is different from many other web application frameworks in that it is compiled. So you have the front-end of your aspx pages which has a mixture of HTML and ASP server-side controls, and then linked to each aspx page you have an aspx.cs code file for the code-behind.

Now, when you're ready to upload your project to the hosting, you should use the Build => Publish menu. This will compile your project in Release mode. All the aspx.cs pages will be compiled into a dll, so you will not see them among the file that are uploaded to the hosting, and you cannot modify them. The aspx pages are typically not compiled (although you can configure that), so you will see them and you can still modify them.

As for the database connection, when you're writing your code, you typically connect a local database on your computer. You should have the connection string in the web.config file in the root folder of your project. However, the connection string for the hosted database is likely to be different, so make sure you have the correct connection string for the hosted database in the web.config before you upload your code to the hosting.

Racil Hilan
  • 24,690
  • 13
  • 50
  • 55
  • Thank you for your tips Racil. Your explanation is clear and appreciated. – Dean Dec 31 '17 at 03:35
  • any idea why i am getting this message when the button(Signup) is click on the live website. it works perfect in the local using Vb studio , but when on webhost and clicked produce this error mentioning the local folder in which the app resides-------- [NullReferenceException: Object reference not set to an instance of an object.] TRACKMEMB.SignUp.BtnSignup_Click(Object sender, EventArgs e) in C:\Users\DEAN COLLINS\Desktop\Projects\TRACKMEMB\TRACKMEMB\SignUp.aspx.cs:35 – Dean Dec 31 '17 at 03:50
  • 1
    Please don't post questions in comments. Create a new question and post all relevant info. The more detailed info you post, the easier you make it for others to help you. Also consider voting on the answers to your questions. – Racil Hilan Dec 31 '17 at 05:06