Asp.net中运用css
在web开发中经常会碰到css样式的运用,我就在asp.net中运用样式进行了总结!
1、使用style属性设置样式
•
n实例
•Style属性设置
<asp:TextBox ID="TextBox1" runat="server"
style="background-color:Red; font-size:15px">
</asp:TextBox>
2、使用Cssclass属性设置样式步骤
•创建css样式表
<style type="text/css">
.textStyle { BORDER-LEFT-COLOR: red; BORDER-BOTTOM-COLOR: red; FONT: 14pt verdana; WIDTH: 300px; BORDER-TOP-STYLE: dashed; BORDER-TOP-COLOR: red; BORDER-RIGHT-STYLE: dashed; BORDER-LEFT-STYLE: dashed; BACKGROUND-COLOR: yellow; BORDER-RIGHT-COLOR: red; BORDER-BOTTOM-STYLE: dashed }
</style>
•设置CssClass属性
<asp:TextBox ID="TextBox1" runat="server" CssClass="textStyle">
3、使用Style类
n声明Style类的步骤
•声明Style对象
•设置Style对象的属性
•
Style style = new Style();
style.BorderColor = System.Drawing.Color.Red;
style.BorderStyle = BorderStyle.Dotted;
style.BorderWidth = 1;
TextBox1.ApplyStyle(style);
将Style对象应用到Web服务器控件
相关文档:
偶尔使用,简单的记录下过程
1.下载Newtonsoft.Json.Net20.dll后,放入Asp.net项目Bin文件夹中.
Newtonsoft.Json.Net20,是一个Object/Json转换工具,这里用来把对象转换成Json格式字符串.
2.树节点Model对象,
public class TreeModel{
private string _i ......
1.关闭不必要的Session
<%@ Page EnableSessionState="flase"%>
2.关闭不必要的ViewState
<asp:DataGrid EnableViewState="false" runat="server">
如果页面级
<%@ Page EnableViewState="false"%>
3.不要使用Exception控制程序流程
Exception是很耗资源的
4.禁用VB和JScript动态数 ......
出现错误发送Email
可以在Global.asax的void Application_Error(Object sender,EventArgs e)
{
//用到了Ssytem.Net.Mail
MailMessage mail=new MailMessage();
mail.from=new MailAddress("automated@contoso.com");
mail.Subject="SIte Error at" +DateTime.Now;
mail.Body="E ......
1、添加一个网站地图项 Web.sitemap项
2、在 Web.sitemap项的写法如下:
<?xml version="1.0" encoding="utf-8"?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0
">
<siteMapNode url="default.aspx" title="首页&qu ......
假定有一个Product表,字段有(Id,Name,Quantity,...)将Quantity列用textbox格式来显示:
首先在Gridview中,Quantity列以TemplateField显示,其他的列属性设为只读,把显示格式设为TextBox
<asp:TemplateField HeaderText="Quantity">
<ItemTemplate>
&nbs ......