带状疱疹是怎样引起的:C#常用代码_网站集粹
来源:百度文库 编辑:偶看新闻 时间:2024/05/02 18:12:16
C#常用代码 Asp.net 中DataGrid多个参数链接设置
1、链接带多个参数。
DataNavigateUrlField="au_id"
DataNavigateUrlFormatString="View_details.aspx?id={0}"
Text="详细信息"
/>
‘ Runat="server">
页面之间传递参数.
之前已经知道怎么取参数了,但是还没有真正去实践过,今天实践了一下,还是遇到了一定的问题.
XXXX.aspx?key=value
这个就是发出参数的页面的格式
当然也可以进行以下encode
用URLencode()方法.
在接收参数值得页面,用Request[string param].toString();来取得string型的参数.
当然也可以先加URLDecode()方法
或者使用Request.QueryString[index];
但是对Request.QueryString.GetValues(index)就不知道怎么用才合适了.
还有对于在中添加<%#DataBinder.Eval(Container.DataItem."xxxxx")%>时提示html错误的问题,请参考以下的例子:
‘ NavigateUrl=‘list.aspx?city=<%#DataBinder.Eval(Container.DataItem, "ID") %>‘ ID="Hyperlink1">
现在基本上显示就ok了
1.清空Cookie
Cookie.Expires=[DateTime];
Response.Cookies("UserName").Expires = 0
2.Panel 横向滚动,纵向自动扩展
3.回车转换成Tab
onkeydown="if(event.keyCode==13) event.keyCode=9"
示例:http://dotnet.aspx.cc/exam/enter2tab.aspx
4.数字格式化
【<%#Container.DataItem("price")%>的结果是500.0000,怎样格式化为500.00?】
<%#Container.DataItem("price","{0:¥#,##0.00}")%>
int i=123456;
string s=i.ToString("###,###.00");
5.日期格式化
【aspx页面内:<%# DataBinder.Eval(Container.DataItem,"Company_Ureg_Date")%>
显示为: 2004-8-11 19:44:28 我要:2004-8-11 】
<%# DataBinder.Eval(Container.DataItem,"Company_Ureg_Date","{0:yyyy-M-d}")%>
××.ToString("yyyy-MM-dd")
6大小写转换
HttpUtility.HtmlEncode(string);
HttpUtility.HtmlDecode(string)
7.设定全局变量
Global.asax中
Application_Start()事件中
添加Application[属性名] = xxx;
就是你的全局变量
8. 打开新的窗口并传送参数:
传送参数:
response.write("")
接收参数:
string a = Request.QueryString("id");
string b = Request.QueryString("id1");
9.为按钮添加对话框
Button1.Attributes.Add("onclick","return confirm(‘确认?‘)");
button.attributes.add("onclick","if(confirm(‘are you sure...?‘)){return true;}else{return false;}")
10.页面控件的引用
parent.document.all.名称.属性=‘值‘;
window.opener.document.getElementById("TextBox1").value = "想要传回父页面的值";
11.随机数产生
Random ro = new Random(System.Environment.TickCount);
12.textbox自动转换为大写
13.正则表达式,只允许输入汉字,但允许汉字之间有空格,但如果空格未出现在两个汉字间,则是非法 。
var reg=/^[\u4e00-\u9fa5](\s*[\u4e00-\u9fa5])*$/;
或者/^[\u4e00-\u9fa5]+$/.test(val.replace(/\s/g,""))
14.两个相同页面Session互相分开(Cache一样处理)
string pageguid = system.guid.pageguid;
Session[YourName+pageguid ] = object;//Cache[YourName+pageguid ] = object;
15.SqlServer查询保存为Excel表格
EXEC master..xp_cmdshell ‘bcp "select customer from sf.dbo.tbl_customer" queryout "c:\test.xls" /c‘
16.后台代码调用div
页面代码中定义div,作为服务器控件运行,ID:aaa
后台代码:
protected System.Web.UI.HtmlControls.HtmlGenericControl aaa;
1、链接带多个参数。
DataNavigateUrlFormatString="View_details.aspx?id={0}"
Text="详细信息"
/>
页面之间传递参数.
之前已经知道怎么取参数了,但是还没有真正去实践过,今天实践了一下,还是遇到了一定的问题.
XXXX.aspx?key=value
这个就是发出参数的页面的格式
当然也可以进行以下encode
用URLencode()方法.
在接收参数值得页面,用Request[string param].toString();来取得string型的参数.
当然也可以先加URLDecode()方法
或者使用Request.QueryString[index];
但是对Request.QueryString.GetValues(index)就不知道怎么用才合适了.
还有对于在
现在基本上显示就ok了
1.清空Cookie
Cookie.Expires=[DateTime];
Response.Cookies("UserName").Expires = 0
2.Panel 横向滚动,纵向自动扩展
3.回车转换成Tab
onkeydown="if(event.keyCode==13) event.keyCode=9"
示例:http://dotnet.aspx.cc/exam/enter2tab.aspx
4.数字格式化
【<%#Container.DataItem("price")%>的结果是500.0000,怎样格式化为500.00?】
<%#Container.DataItem("price","{0:¥#,##0.00}")%>
int i=123456;
string s=i.ToString("###,###.00");
5.日期格式化
【aspx页面内:<%# DataBinder.Eval(Container.DataItem,"Company_Ureg_Date")%>
显示为: 2004-8-11 19:44:28 我要:2004-8-11 】
<%# DataBinder.Eval(Container.DataItem,"Company_Ureg_Date","{0:yyyy-M-d}")%>
××.ToString("yyyy-MM-dd")
6大小写转换
HttpUtility.HtmlEncode(string);
HttpUtility.HtmlDecode(string)
7.设定全局变量
Global.asax中
Application_Start()事件中
添加Application[属性名] = xxx;
就是你的全局变量
8. 打开新的窗口并传送参数:
传送参数:
response.write("")
接收参数:
string a = Request.QueryString("id");
string b = Request.QueryString("id1");
9.为按钮添加对话框
Button1.Attributes.Add("onclick","return confirm(‘确认?‘)");
button.attributes.add("onclick","if(confirm(‘are you sure...?‘)){return true;}else{return false;}")
10.页面控件的引用
parent.document.all.名称.属性=‘值‘;
window.opener.document.getElementById("TextBox1").value = "想要传回父页面的值";
11.随机数产生
Random ro = new Random(System.Environment.TickCount);
12.textbox自动转换为大写
13.正则表达式,只允许输入汉字,但允许汉字之间有空格,但如果空格未出现在两个汉字间,则是非法 。
var reg=/^[\u4e00-\u9fa5](\s*[\u4e00-\u9fa5])*$/;
或者/^[\u4e00-\u9fa5]+$/.test(val.replace(/\s/g,""))
14.两个相同页面Session互相分开(Cache一样处理)
string pageguid = system.guid.pageguid;
Session[YourName+pageguid ] = object;//Cache[YourName+pageguid ] = object;
15.SqlServer查询保存为Excel表格
EXEC master..xp_cmdshell ‘bcp "select customer from sf.dbo.tbl_customer" queryout "c:\test.xls" /c‘
16.后台代码调用div
页面代码中定义div,作为服务器控件运行,ID:aaa
后台代码:
protected System.Web.UI.HtmlControls.HtmlGenericControl aaa;
求Asp.net 用C#编写的简单网站代码!!!
哪里有网站制作常用代码的学习
求:c#反射代码
帮忙看下这段c#代码
c#编程改代码
c#代码改编
.NET C# 代码解释
.NET C# 代码解释
看一段c#代码
c#代码安装数据库
c# label 显示时间代码
看一段c#代码 难度
这段代码是什么意思?C#
求救!有关C#常用名称空间
-------------^_^搜寻MTV网站^_^
我不怎么会写英文简历(英语专业),哪位高手能介绍几个网站 或简单的格式_常用词语?
c#语言网站制作
c#制作wap网站
qq封代码后常用代码
常用的观察记录代码
主板诊断卡常用代码~
主板诊断卡常用代码~
用C#求素数的代码!!
Visual Studio2003中c#代码详解