can .cs contain html code? no.cs is called code-behind file, by separating your server code into a .cs, you separate presentation from logic. The benefits are:1. you can change them separately, so a designer can change the html and an engineer can change the c# code independently
2. .cs file is compiled into a dll and  people cannot see your source code (although it is possible to decompile the dll into source code unless you use an obfuscator to make it harder to do so)
3. you can reuse your c# code in other places

解决方案 »

  1.   

    cs文件中装代码,这里的源码别人是看不到的,比较安全,ASPX中最好只是作页面设计,控件都在ASPX中,这样代码看的清楚,你打开新建项目中会看到.CS代码的文件有哪些,很容易懂。
      

  2.   

    cs文件:是存放所有逻辑的地方
    ASPX中:是展示所有外观效果的地方
      

  3.   

    .aspx和.cs,这是Code-Behind结构,即HTML内容在.aspx文件中,代码在.cs文件中。.aspx文件中也可以直接加代码,那是混合模式。使用Code-Behind结构比混合结构好,因为Code-Behind实现了内容和代码分离,这样易于管理、层次清楚、能够实现所见即所得。
      

  4.   

    .cs文件是.aspx文件的后台绑定文件,将一些后台处理的逻辑放在其中。
      

  5.   

    最主要的还是体现在外观和代码分离上,如果你做比较大型,但是内容经常重复的系统,用这种方式比较好c & p    ^-^
    如果东西放在一起,当你对你的程序进行维护的时候,特别是只是修改一下html代码的时候,会发现那是多么让人抓狂,简简单单得页面,集中代码累加起却要好几页
      

  6.   

    .aspx和.cs,这是Code-Behind结构,即HTML内容在.aspx文件中,代码在.cs文件中。.aspx文件中也可以直接加代码,那是混合模式。使用Code-Behind结构比混合结构好,因为Code-Behind实现了内容和代码分离,这样易于管理、层次清楚、能够实现所见即所得。
    支持以上观点~