web网页
Posted 玉滨的博客
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了web网页相关的知识,希望对你有一定的参考价值。
前端代码:
<%@ 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 id="form1" runat="server">
<div id="div_chk"
style = "width:1000px;border:3px outset #dd9900;margin:54px auto 0 auto;backgroup:red"
runat="server">
你学过的课程有:<br/>
<asp:CheckBox ID="C1" Text = "数据库原理" Width = "260px" runat="server" />
<asp:CheckBox ID="C3" Text = "操作系统" Width = "260px" runat="server" />
<asp:CheckBox ID="C5" Text = "c语言" Width = "260px" runat="server" />
<asp:CheckBox ID="C6" Text = "计算机网络" Width = "260px" runat="server" />
<asp:CheckBox ID="C7" Text = "管理学" Width = "260px" runat="server" />
<asp:CheckBox ID="C8" Text = "电子商务" Width = "260px" runat="server" />
<asp:CheckBox ID="C9" Text = "计算机基础" Width = "260px" runat="server" />
<br/>
<asp:Button ID="Button1" runat="server" Text="确定" onclick="Button1_Click" />
<br/>
<asp:TextBox ID="TextBox1" TextMode ="Multiline" Rows = "6" runat="server"></asp:TextBox>
<br/>
<br/>
<asp:TextBox ID="TextBox2" TextMode ="Multiline" Rows = "6" runat="server"></asp:TextBox>
<asp:Button ID="Button2" runat="server" Text="确定" onclick="Button2_Click" />
<br/>
<br/>
<div id = "div_sun" runat = "server">
<asp:Button ID="Button3" runat="server" Text="Button" />
<asp:Button ID="Button4" runat="server" Text="Button" />
<asp:Button ID="Button5" runat="server" Text="Button" />
<asp:Button ID="Button6" runat="server" Text="Button" />
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
</div>
<asp:Button ID="Button7" runat="server" Text="显示控件个数" onclick="Button7_Click" />
</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 Button1_Click(object sender, EventArgs e) { TextBox1.Text = ""; CheckBox chk; foreach(Control _ctl in div_chk.Controls){ if(_ctl is CheckBox){ chk = (CheckBox)_ctl; if(chk.Checked == true){ TextBox1.Text +=chk.Text+","; } } } } protected void Button2_Click(object sender, EventArgs e) { char[] str1 = "abcdefg!".ToCharArray(); foreach (char ch in str1) { TextBox2.Text += ch.ToString() + Convert.ToChar(13); } } protected void Button7_Click(object sender, EventArgs e) { Button bu; TextBox te; int i=0; int j=0; foreach (Control bt in div_sun.Controls) { if (bt is Button) { i++; } if (bt is TextBox) { j++; } } Response.Write("按钮控件"+i.ToString() + "个" + "</br>"); Response.Write("文本框控件" + j.ToString() + "个" + "</br>"); } }
以上是关于web网页的主要内容,如果未能解决你的问题,请参考以下文章
在Tomcat的安装目录下conf目录下的server.xml文件中增加一个xml代码片段,该代码片段中每个属性的含义与用途