日期:2014-05-17 浏览次数:20471 次
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default"
ViewStateMode="Disabled" %>
<!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></title>
<script type="text/javascript" language="javascript">
function window.onload() {
// alert('111');
alert(document.getElementById("lbl_red").innerText);
}
function RedColor() {
window.document.getElementById("Button1").click();
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="btn_change" runat="server" Text="变色" OnClientClick="RedColor();" />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
</div>
<div>
<asp:Label ID="lbl_red" runat="server" Width="100px" ViewStateMode="Disabled"></asp:Label>
<br />
<asp:Label ID="lbl_green" runat="server" Text="Green" Width="100px"></asp:Label>
<br />
<asp:Label ID="lbl_blue" runat="server" Text="Blue" Width="100px"></asp:Label>
</div>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void RedColor(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
this.lbl_red.Text = "***";
// ClientScript.RegisterStartupScript(this.GetType(), "", "<script type='tex