日期:2014-05-17 浏览次数:20502 次
<%@ 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>无标题页</title>
</head>
<body>
<form runat="server" id="form1">
<asp:TextBox ID="txt" runat="server" />
<asp:TextBox ID="TextBox1" runat="server" />
<asp:TextBox ID="TextBox2" runat="server" />
<asp:TextBox ID="TextBox3" runat="server" />
<asp:TextBox ID="TextBox4" runat="server" />
<asp:TextBox ID="TextBox5" runat="server" />
<asp:TextBox ID="TextBox6" runat="server" />
<asp:TextBox ID="TextBox7" runat="server" />
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Data;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
foreach (Control item in form1.Controls)
{
if (item is TextBox)
{
((TextBox)item).ReadOnly = true;
}
}
}
}