<script runat="server">
</script>
里面可以加入后台代码对吧,我想问的是该怎么加呢?是全部复制代码还是跟点击按钮一样直接进入OnClick事件里面呢?

解决方案 »

  1.   

    <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Style="z-index: 100;
                left: 322px; position: absolute; top: 148px" Text="Button" />
    <script runat="server">    protected void Button1_Click(object sender, EventArgs e)
        {    }
    </script>
    你可以在新建页面的时候把”将代码放在单独的文件中“复选框勾掉(不选择)。
      

  2.   

    有时候你为了能在后台向前台指定位置输出HTML(比如数据表格),就在前台引用一个变量,然后在后台定义这个变量(也许我顺序说错了)并对这个变量赋值。//ex.:
    //aspx:
    <!--
    下面这句话可以放到你想插入的地方,比如表格的某个单元格。
    -->
    <% = html %>
    //aspx.cs:using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;public partial class Interface_Department_DepartmentIndex : System.Web.UI.Page
    {
         protected string html = "";
     protected void Page_Load(object sender, EventArgs e)
        {
          html="<font color =red>This is an ex.</font>";
        }
    }