随笔分类 - ASP.NET
摘要:方法一: 或: 这样可以实现将多个按钮发送到不同的网页中。方法二:提交form的时候,里面的action不能带参数,例: 通过这个方法,test.do无法读取args,必须换成以下写法
阅读全文
摘要:/// /// 获取汉字首字母(可包含多个汉字) /// /// /// public string GetChineseSpell(string strText) { int len = strText.Length; string myStr = ""; for (int i = 0; i 1) { int area = (short)arrCN[0]; int pos = (short)arrCN[1]; int code = (...
阅读全文
摘要:/// /// 弹出对话框(确定后页面会错位) /// /// /// public string MessageBox1(string TxtMessage) { string str; str = ""; return str; } /// /// 弹出对话框,不需要Response.Write(...) /// /// public void MessageBox(string TxtMessage) { Page page = (P...
阅读全文
摘要:login.aspx文件(刷新页面)或(只刷新验证码)login.aspx.cs文件if (Request.Cookies["ValidateCookie"].Values["Chcode"].ToString().ToLower() == this.txtCode.Text.Trim().ToString().ToLower()) { ... }valicode.aspx.cs文件protected void Page_Load(object sender, EventArgs e) { string chcode = ""; //
阅读全文
摘要:1 protected void updown() 2 { 3 int id = Convert.ToInt32(Request.QueryString["id"].ToString()); 4 string sqlUp = string.Format("select top 1 title, max(id) as id from blog where id<'{0}' group by title order by id desc",id); 5 string sqlDown = string.Format("selec
阅读全文
摘要:function Format function Format(const Format: string; const Args: array of const): string; overload; Format参数是一个格式字符串,用于格式化Args里面的值的。Args又是什么呢,它是一个变体数组,即它里面可以有多个参数,而且每个参数可以不同。 如以下例子: Format('my name is %6s',['wind']); 返回后就是 my name is wind 现在来看Format参数的详细情况: Format里面可以写普通的字符串,比如'
阅读全文
摘要:/// <summary> /// 生成随机密码 /// </summary> /// <returns></returns> public string GetNewPwd() { return Membership.GeneratePassword(16,0); }注释: // // 摘要: // 生成指定长度的随机密码。 // // 参数: // length: // 生成的密码的字符数。长度必须介于 1 和 ...
阅读全文
摘要:public static string SubStr(string sString, int nLength) { if (sString.Length <= nLength) { return sString; } string newStr = sString.Substring(0,nLength); newStr = newStr + "..."; return newStr; }
阅读全文
摘要://获取日期+时间DateTime.Now.ToString(); // 2008-9-4 20:02:10DateTime.Now.ToLocalTime().ToString(); // 2008-9-4 20:12:12 //获取日期DateTime.Now...
阅读全文
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace 体积{ class Program { static void Main(string[] args) { double tj,a,b,c; Console.WriteLine("请输入第一个数字:"); a = Convert.ToDouble(Console.ReadLine()); ...
阅读全文
摘要:class ForEachTest{ static void Main(string[] args) { int[] fearray = new int[] { 0, 1, 2, 3 }; foreach (int i in fearray) { System.Console.WriteLine(i); } }}输出:0123
阅读全文
摘要:在Visual Studio 2008中建立新文件时,会出现:“using System.Linq命名空间无法引用”解决方法:在解决方案上点击右键--添加引用--浏览---找到Microsoft.Net-SDK-CompactFramework-v3.5-WindowsCE-System.Xml.Linq.dll文件,然后点击确定。出现命名空间“System.Xml”中不存在类型或命名空间名称“Linq”(是缺少程序集引用吗?) 是什么回事? 直接把 using System.Linq; 和 using System.Xml.Linq;删除就不会出现这个错误了,如果项目的框架版本是.net .
阅读全文
摘要:<asp:Image runat="server" width="150" height="100" ImageUrl='<%#FormatImageURL(eval("PicPath"))%>'>/>//PicPath为数据库中存放图片的字段名,路径在代码中拼出来即可--------------------------------------------| id | UserName | Age | PicPath ||------------------------
阅读全文
摘要:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head> <title>无刷新评论</title> <script type="text/javascript">
阅读全文
摘要:protected void gvBookTaxis_RowDataBound(object sender, GridViewRowEventArgs e) { if (gvBookTaxis.PageIndex == 0)//判断是否是从第一页开始 { if (e.Row.RowIndex != -1) //判断GridView控件中是否有值 { int id = e.Row.RowIndex + 1;//将当前行的索引加上一赋值给变量id e.Row...
阅读全文