ASP.Net学习笔记002--ASP.Net服务端控件做了什么2

ASP.Net学习笔记002--ASP.Net服务端控件做了什么2

以前写的课程都没有附上源码,很抱歉!
课程中的源码可以加qq索要:1606841559
技术交流qq1群:251572072
技术交流qq2群:170933152
也可以自己下载:
ASP.Net学习笔记002ASP.Net服务端控件做了什么2.zip
http://credream.7958.com/down_20144361.html
1.程序结构
项目中:
WebForm1.aspx下有两个文件:
WebForm1.aspx中代码:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    </div>
    //原来的html代码也可以和asp.net引擎中的控件写到一起
    //   <input type ="button;" name ="" />
    //1.注意这里的button;后需要加引号,否则会出现由于xml规则引起的警告
    //2.
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
    <asp:Button ID="Button1" runat="server" οnclick="Button1_Click" Text="Button" />
    <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
    </form>
</body>
</html>
------------------------------------------------------
  <input id ="abc"  type="Button" value ="tuzhu" runat="server"  />
   <!--
   1.runat="server"有这句的是服务器控件,没这句的是html控件
   -->
-------------------------------------------------------------------
WebForm1.aspx.cs用于写逻辑
WebForm1.aspx.designer.cs
-----------------------------------------------------------
上课中的例子,asp.net引擎会自动生成如下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 method="post" action="WebForm1.aspx" id="form1">
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJODcwNjAxNTI1ZGRiIB7rVQurxN6PSjZOEyCrkP00D6r1puuxdi+HAKhLLw==" />
</div>
<div class="aspNetHidden">
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWBQLu3v3PDALs0bLrBgLs0fbZDAKM54rGBgLs0Yq1BZ6QsF/eCv2iwBXy0TytLvnomEZFJdI8yJ+PesYxhzgI" />
</div>
    <div>
    </div>
    <input name="TextBox1" type="text" value="2" id="TextBox1" />
    <input name="TextBox2" type="text" value="3" id="TextBox2" />
    <input type="submit" name="Button1" value="Button" id="Button1" />
    <input name="TextBox3" type="text" value="5" id="TextBox3" />
    </form>
</body>
</html>


-------------------------------------------------------------------
ASP.Net中可以写入原生态的html和JavaScript
比如:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebForm.WebForm1" %>


<!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">
    <script src ="Scripts/jquery-1.4.1.min.js" type="text/javascript" ></script>
    <script type ="text/javascript" language ="javascript" >
        $(function () {
            $("#TextBox3").mouseover(function () {
                $(this).css("color", "Red");
            });
        });


    </script>
    <div>
    </div>
    <!--  <input id ="abc"  type="Button" value ="tuzhu" runat="server"  />
  1.runat="server"有这句的是服务器控件,没这句的是html控件
   服务器控件,服务器控件可以在代码中.出来
   <asp:Button ID ="MyControl" runat ="server" />  
   1.asp.net控件也可以自己写
   -->
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
    <asp:Button ID="Button1" runat="server" οnclick="Button1_Click" Text="Button" />
    <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
    </form>
</body>
</html>
------------------------------------------------------------------

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

添柴程序猿

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值