protected void Page_Load(object sender, EventArgs e)
{
   string myScript = @"alert(document.forms[0]['Label1'].value;)";   Page.ClientScript.RegisterStartupScript(this.GetType(), "MyScript", myScript, true);      
}<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %><!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 id="Title1" runat="server">无标题页</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Label ID="Label1" runat="server" Text="Label">aaa</asp:Label>
        </div>
    </form>
</body>
</html>------------------------------------------------------------------
执行后的HTML
<!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><title>
无标题页
</title></head>
<body>
    <form name="form1" method="post" action="Default.aspx" id="form1">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMTcyMTYyMjM5NmRkZdqwnR4d9teWOEPkUQTLVxGRQps=" />
</div>    <div>
        <span id="Label1">aaa</span>
        <input type="submit" name="Button1" value="Button" id="Button1" /></div>
    
<div> <input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWAgL5mKTeAgKM54rGBvLIeDMJhguFT2LbZlAJJbn9It8H" />
</div><script type="text/javascript">
<!--
alert(document.forms[0]['Label1'].value;)// --><!--行22,字符40-->
</script>
</form>
</body>
</html>
行22,字符40错误:缺少')'