开发者

How do I edit an asp.net site? Changes I make to .cs files, don't affect anything

So, I need to make changes to an asp.net built site that was recently handed to me. The problem is that I'm a php coder and I don't know jack about asp.net development.

The page I am trying to modify is associated with the contact form. In the contact folder, there is a default.aspx with the following code:

<%@ Page language="c#" Codebehind="default.aspx.cs" 
  AutoEventWireup="false" Inherits="watergrass.contact._default" %>

So then I found the default.aspx.cs and poked around in the code. It made sense,开发者_如何学Python so I made a few changes, but nothing happened when I refreshed the browser. So then I deleted all of the file's content and realized nothing changed again. At this point I'm like WTF? So, my assumption is that I need to re-compile the site or something along those lines? If so, how would I go about doing this?

If anyone has some pointers, they would be greatly appreciated!


  1. That's ASP.Net - ASP is something different =)
  2. Coming from PHP you probably didn't know that .cs files need to be compiled, and then redeployed. No harm no foul, but go read up about that. It can be different in different circumstances - for simple solutions you can launch a debug webserver with F5 that will preview your changes. For more complex apps (like what we use at work) we run a production IIS setup on our local machines. Try F5, see if that does it.


Try downloading Visual Web Developer and opening the site with that. There should be a project file somewhere that will show up when you select open project from the menu.


I'm assuming you are using Visual Studio. Rebuild the project after making changes to .cs files. You don't have to rebuild when you only make changes to .aspx files.


Maybe you should download Visual Web Developer Express and try to make some simpler sites. The point is that all .cs code is normally compilled into a dll in your site's bin directory.


You don't have to use code-behind(I don't recommend it) and you can have the code inline much like classic ASP.

INFO: ASP.NET Code-Behind Model Overview

<%@ Language=C# %>
<HTML>
   <script runat="server" language="C#">
   void MyButton_OnClick(Object sender, EventArgs e)
   {
      MyLabel.Text = MyTextbox.Text.ToString();
   }
   </script>
   <body>
      <form id="MyForm" runat="server">
         <asp:textbox id="MyTextbox" text="Hello World" runat="server"></asp:textbox>
         <asp:button id="MyButton" text="Echo Input" OnClick="MyButton_OnClick" runat="server"></asp:button>
         <asp:label id="MyLabel" runat="server"></asp:label>
      </form>
   </body>
</HTML>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜