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服务器控件
相关文档:
在Web编程过程中,存在着很多安全隐患。比如在以前的ASP版本中,Cookie为访问者和编程者都提供了方便,并没有提供加密的功能。打开IE浏览器,选择“工具”菜单里的“Internet选项”,然后在弹出的对话框里单击“设置”按钮,选择“查看文件”按钮,在弹出的窗口中,就会显示硬盘里 ......
在ASP.NET中,我们可以用下面的方法实现从数据库中读取图片并显示在页面上,方法如下:
SqlConnection conn=new SqlConnection(ConfigurationSettings.AppSettings["ConnStr"]);
String sql="SELECT image from append where id='" + strID + "'";
&n ......
网站文件名:
1、 网站文件名以标准英文单词描述业务内容。如果1个英文单词无法描述,可以增加2个或者3个,但尽量为完全单词,例如article.aspx/ articleView.aspx / articleList.aspx 等。
2、 文件名尽量不用数字描述。
3、 文件名尽量不能太长,以不超过20个字母为宜。
4、 图片文件名尽量描述图片内容分类。尽量 ......
此处提供的代码用来实现当asp.net页面中的某个Button被点击后disable掉该页面中所有的Button,从而防止提交延时导致的多次提交。基于之前的onceclickbutton脚本.
//ASP.NET中防止页面多次提交的代码:javascript< script language="javascript"> < !-- function disableOtherSubmit() {
var obj = event.s ......
假定有一个Product表,字段有(Id,Name,Quantity,...)将Quantity列用textbox格式来显示:
首先在Gridview中,Quantity列以TemplateField显示,其他的列属性设为只读,把显示格式设为TextBox
<asp:TemplateField HeaderText="Quantity">
<ItemTemplate>
&nbs ......