###CSS学习
CSS特点:实现网页内容与样式分离
1、选择器优先级
id选择器>类选择器>标签选择器
2、CSS核心内容
标准流、盒子模型、浮动、定位
3、块级元素、行内元素
块级元素单独占一行
行级元素并排
####盒模型:
外边距:margin
内边距:padding
内容:height、width
外框:border
####浮动 float
清除浮动:clear
####定位 Position
Relative:相对定位
absolute:绝对定位,根据父标签来进行定位
####在新窗口打开
Target="_blank"
####符号:
© &
####让div居中
margin-left: 10px auto 10px auto;
####Eval 绑定
使用:<%# Eval("id")%>
####GridView控件
设置控件的css样式
CssClass=""
设置th标签的css样式
HeaderStyle-CssClass=""
设置td标签的css样式
ItemStyle-CssClass=""
####传输中文
Server.UrlDecode(); //解码
Server.UrlEncode(); //编码
####弹出提示框
OnClientClick="return confirm('是否要真的删除该评论')"
####页面记住滚动条的位置
//在第一行语句也就是page标签中添加下面属性
MaintainScrollPositionOnPostback="true"
####添加锚记
在超链接标签中使用name属性, 跳转使用href="#name"
####获取ip地址
Request.ServerVariables["REMOTE_ADDR"];
####.net中获取字符串的MD5码
//1、导入命名控件:
Using System.Web.Security;
//2、获取MD5码
String password=FormsAuthentication.HashPasswordForStoringInConfigFile(TextBox1.Text.ToString(),"MD5")
####在“页面”上屏蔽回车键
//屏蔽Enter按键
$(document).keydown(function (event) {
switch (event.keyCode) {
case 13: return false;
}
});
####使用ajax扩展控件
//(1)添加SciptManager控件
//(2)添加UpdatePanel控件,将需要局部更新的内容区域放到该标签的<ContentTemplate> 中
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
//局部刷新内容
</ContentTemplate>
</asp:UpdatePanel>
####让asp.net 可以提交不安全的代码
在aspx开头的第一行代码中添加 ValidateRequest="false"
####下拉控件绑定DataTable
ddlCategory.DataSource = dt;
ddlCategory.DataTextField = "name";
ddlCategory.DataValueField = "id";
ddlCategory.DataBind();
####GridView分页
//设置GridView控件的AllowPaging属性为true
//设置PageSize 每页的个数
//添加代码:
Protected void GridView1_PageIndexChanging(object sender,GridViewPageEventArgs e)
{
GridView1.PageIndex=e.NewPageIndex;
//重新绑定 就可以了。
}
####关于分页
aspNetPager控件的使用
####SQL语句的分页
ROW_NUMBER() 函数
With tempTable as (
Select ROW_NUMBER() over(order by id desc) as 行号, * from news
)
Select * from tempTable where 行号 between 9 and 16