参考:通俗易懂,什么是.NET?什么是.NET Framework?什么是.NET Core?
ASP.NET 应用程序默认文件夹
ASP.NET网页扩展名
.ascx
Web用户控件htm
HTML页xml
XML页.master
母版页.asmx
Web服务.asax
全局应用程序类.config
Web配置文件.sitemap
网站地图skin
外观文件css
样式表页面指令
<%@Page%>
<%@Import Namespace="Value"%>
一个指令只能导入一个命名空间<%@OutputCache%>
设置用户控件的输出缓存策略<%@Implements Interface="接口名称"%>
<%@Register%>
用于创建标记前缀和自定义控件之间的关联关系注释
<%-- --%>
使用此注释不会输出到浏览器端<!-- -->
服务器端文件包含
<!--#include file|virtual="filename" -->
将指定文件的内容插入 ASP.NET 文件中,包括网页(.aspx 文件)、用户控件文件(.ascx 文件)和 Global.asax 文件。
file
相对文件目录的物理路径virtual
相对网站虚拟目录的虚拟路径 (推荐使用)EnableViewState=false
来禁用ViewState//通过SqlServer身份验证 (安全连接)
string connStr1="Data Source=local;Initial Catalog=DataBaseName;User Id=xx;Password=xx";
//通过Windows身份验证 (可信连接)
string connStr2="Data Source=local;Initial Catalog=DataBaseName;IntegratedSecurity=SSPI";
// Data Source 可简写成 server
// Initial Catalog 可简写成 database
// User Id 可简写成 uid
// PassWord 可简写成 pwd
//使用SqlConnectionStringBuilder
SqlConnectionStringBuilder connStr3 = new SqlConnectionStringBuilder();
connStr3.DataSource =".";//"local"
stringBuilder.InitialCatalog = "DabaBaseName";
stringBuilder.IntegratedSecurity = true;
connectionStrings
节点(推荐) <connectionStrings>
<add name="connStr" connectionString="Data Source=local;Initial Catalog=DataBaseName;User Id=xx;Password=xx" providerName="System.Data.SqlClient" />
</connectionStrings>
appSettings
节点 <appSettings>
<add key="connStr" value="Data Source=local;Initial Catalog=DataBaseName;User Id=xx;Password=xx"/>
</appSettings>
string connStr = ConfigurationManager.ConnectionStrings["connstr"].ConnectionString;
web.config
配置启用AJAX相关设置AJAX是Asynchronous JavaScript and XML(中文译做:异步JavaScript和XML技术)的缩写,它是由JavaScript脚本语言、CSS样式表、XMLHttpRequest数据交换对象和DOM文档对象(或XMLDOM文档对象)等多种技术组成的。
服务器端控件在运行时会自动生成ASP.NET AJAX 客户端组件,并发送给客户端浏览器执行。
客户端控件主要在浏览器上运行,主要提供管理界面元素、调用服务器端方法获取数据等功能。
负责管理Page页面中国所有的AJAX服务器控件。
管理Page页面中所有的AJAX服务器控件,是AJAX的核心。
常用属性:
EnablePageMethods
EnablePartialRendering
EnableScriptComponents
Script
Service
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Scripts>
<asp:ScriptReference Path="~/Scripts/validateName.js" />
</Scripts>
<Services>
<asp:ServiceReference Path="~/RandomService.asmx" />
</Services>
</asp:ScriptManager>
ScriptReference
类常用属性
Assembly
Path
Name
NotifyScriptLoaded
将ASP.NE服务器控件拖放到UpdatePanel控件中,使原本不具备AJAX能力的控件具有AJAX异步功能。
常用属性:
ContentTemplate
(通过<ContentTemplate>
元素声明)Triggers
(通过<Triggers>
元素声明)
AsyncPostBackTrigger
用于引发局部更新PostBackTrigger
用于引发整页更新UpdateMode
(用于UpdatePanel嵌套)
Always
每次Postback后Update会被连带更新Conditional
RenderMode
若RenderMode
的属性为Block
,则以<DIV>
标签来定义程序段;若为Inline
,则以<Span>
标签来定义程序段。(默认为Block
) <asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
rand num:
<br />
<div style="text-align: center; width: 123px; height: 60px; line-height: 60px; background-color: rebeccapurple">
<asp:Label ID="Label1" runat="server" Font-Bold="true" Font-Size="18px" />
</div>
<asp:Button ID="Button1" runat="server" Text="rand num" OnClick="Button1_Click" />
</ContentTemplate>
<!-- 控制UpdatePanel外部的控件局部更新 -->
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button2" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
<asp:Button ID="Button2" runat="server" Text="rand num" OnClick="Button1_Click" />
注意:使用Timer控件可能会加大Web应用程序的负载。在引入自动回发特性前并在确实需要的时候才推荐使用Timer控件,同时尽可能设置更长的间隔时间。
Interval
属性Enable
属性Tick
事件<!--AJAXdemo.aspx-->
<asp:UpdatePanel runat="server">
<ContentTemplate>
<asp:Timer ID="Timer1" runat="server" OnTick="Timer1_Tick" Interval="1000">
</asp:Timer>
<asp:Label ID="TimeNow" runat="server" />
</ContentTemplate>
</asp:UpdatePanel>
//AJAXdemo.aspx.cs (一部分)
protected void Timer1_Tick(object sender, EventArgs e)
{
TimeNow.Text = DateTime.Now.ToString();
}
PasswordStrength
控件TextBoxWatermark
控件SlideShow
控件原文:https://www.cnblogs.com/holm/p/13089900.html