这写法还真怪,为什么不?
 protected void Page_Load(object sender, EventArgs e)
    {
        string aa = "游戏";
       document.getelmentbyid(TextBox1).value=aa;
    }

解决方案 »

  1.   

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm7.aspx.cs" Inherits="WebA.WebForm7" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Untitled Page</title>
        <script runat="server">
        public string aa = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            string aa = "游戏";
            TextBox1.Text = aa;
           
        }
    </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        <asp:TextBox ID="TextBox1" runat="server" Text='<%=aa%>'></asp:TextBox>
        </div>
        </form>
    </body>
    </html>
      

  2.   

    tomsoncat(蝈蝈) 我只是举个例子w275221545c(孤独是为自由付出的代价 试过了,不行的,我没有用代码分离
      

  3.   

    如果绑定的话:
        protected void Page_Load(object sender, EventArgs e)
        {
            string aa = "游戏";
             this.DataBind();
           
        }
    然后: <asp:TextBox ID="TextBox1" runat="server" Text='<%#aa%>'></asp:TextBox>
      

  4.   

    老大 你多半直接复制去考上去了,  
    TextBox1.Text = aa;加在你代码
    string aa = "游戏";
    下面就OK
      

  5.   

    WebA.WebForm7注意这里我是新建的一张叫WebForm7的
      

  6.   

    老弟你可真粗心啊,你在Page_Load里又重新定义了一个aa,那个public的aa还是空呢……另外,为控件绑定属性值,用<%# %>,而不是<%= %>,并且在Page_Load里写DateBind(),类似g_lbz() 说的
      

  7.   

    <%@ Page Language="C#"  %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>pyf</title>
        <script runat="server">
            string aa = string.Empty;
            protected void Page_Load(object sender, EventArgs e)
            {
                 aa = "abc";
                 this.DataBind();
            }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:TextBox ID="TextBox1" runat="server" Text="<%# aa%>"></asp:TextBox>
        </div>
        </form>
    </body>
    </html>这应该就是你要的效果了