我丢块砖,大家来砸玉吧:
==================
子窗体返回主窗体 ///<summary>
///名称:redirect
///功能:子窗体返回主窗体
///参数:url
///返回值:空
///</summary>
public void redirect(string url,Page page)
{
if ( Session["IfDefault"]!=(object)"Default")
{
page.RegisterStartupScript("","<script>window.top.document.location.href='"+url+"';</script>");
}
} 判断是否为数字 /// <summary>
/// 名称:IsNumberic
/// 功能:判断输入的是否是数字
/// 参数:string oText:源文本
/// 返回值: bool true:是 false:否
/// </summary>
public bool IsNumberic(string oText)
{
try
{
int var1=Convert.ToInt32 (oText);
return true;
}
catch
{
return false;
}
} 获得字符串实际长度(包括中文字符) //获得字符串oString的实际长度
public int StringLength(string oString)
{
byte[] strArray=System.Text .Encoding.Default .GetBytes (oString);
int res=strArray.Length ;
return res;
} 将回车转换为TAB //当在有keydown事件的控件上敲回车时,变为tab
public void Tab(System.Web .UI.WebControls .WebControl webcontrol)
{
webcontrol.Attributes .Add ("onkeydown", "if(event.keyCode==13) event.keyCode=9");
} datagrid分页中如果删除时出现超出索引 public void jumppage(System.Web.UI.WebControls.DataGrid dg)
{
int int_PageLess; //定义页面跳转的页数
//如果当前页是最后一页
if(dg.CurrentPageIndex == dg.PageCount-1)
{
//如果就只有一页
if(dg.CurrentPageIndex == 0)
{
//删除后页面停在当前页
dg.CurrentPageIndex = dg.PageCount-1;
}
else
{
//如果最后一页只有一条记录
if((dg.Items.Count % dg.PageSize == 1) || dg.PageSize == 1)
{
//把最后一页最后一条记录删除后,页面应跳转到前一页
int_PageLess = 2;
}
else //如果最后一页的记录数大于1,那么在最后一页删除记录后仍然停在当前页
{
int_PageLess = 1;
}
dg.CurrentPageIndex = dg.PageCount - int_PageLess;
}
}
}
==================
子窗体返回主窗体 ///<summary>
///名称:redirect
///功能:子窗体返回主窗体
///参数:url
///返回值:空
///</summary>
public void redirect(string url,Page page)
{
if ( Session["IfDefault"]!=(object)"Default")
{
page.RegisterStartupScript("","<script>window.top.document.location.href='"+url+"';</script>");
}
} 判断是否为数字 /// <summary>
/// 名称:IsNumberic
/// 功能:判断输入的是否是数字
/// 参数:string oText:源文本
/// 返回值: bool true:是 false:否
/// </summary>
public bool IsNumberic(string oText)
{
try
{
int var1=Convert.ToInt32 (oText);
return true;
}
catch
{
return false;
}
} 获得字符串实际长度(包括中文字符) //获得字符串oString的实际长度
public int StringLength(string oString)
{
byte[] strArray=System.Text .Encoding.Default .GetBytes (oString);
int res=strArray.Length ;
return res;
} 将回车转换为TAB //当在有keydown事件的控件上敲回车时,变为tab
public void Tab(System.Web .UI.WebControls .WebControl webcontrol)
{
webcontrol.Attributes .Add ("onkeydown", "if(event.keyCode==13) event.keyCode=9");
} datagrid分页中如果删除时出现超出索引 public void jumppage(System.Web.UI.WebControls.DataGrid dg)
{
int int_PageLess; //定义页面跳转的页数
//如果当前页是最后一页
if(dg.CurrentPageIndex == dg.PageCount-1)
{
//如果就只有一页
if(dg.CurrentPageIndex == 0)
{
//删除后页面停在当前页
dg.CurrentPageIndex = dg.PageCount-1;
}
else
{
//如果最后一页只有一条记录
if((dg.Items.Count % dg.PageSize == 1) || dg.PageSize == 1)
{
//把最后一页最后一条记录删除后,页面应跳转到前一页
int_PageLess = 2;
}
else //如果最后一页的记录数大于1,那么在最后一页删除记录后仍然停在当前页
{
int_PageLess = 1;
}
dg.CurrentPageIndex = dg.PageCount - int_PageLess;
}
}
}
解决方案 »
- 我用vs2005 写的程序在Win7上不能运行是个什么原因?----在线等
- 表达式计算的错误
- 新建安装项目的时候说:没有注册类别
- 关于DataGridView和数据库绑定的问题
- 在SqlServer2000开发,如何发布到MSDE2000上
- 问下关于Form传递的问题
- 各为C#的先驱者,小弟才开始学C#,请推荐本入门级的书?各位入门的是哪本书?
- remoting 中客户端向服务器端发出服务请求的时候,服务器如何获得这个请求的消息呢?
- 再散100分!终于离开软件行业了,散分给还在里面挣扎的朋友们!
- 大家看看这个是怎么回事,char居然可以自动转化为int
- 面向過程編程和面向對象編程的各自特點和異同
- 今天第二个问题.这个可能我脸皮比较厚.所以大家不要笑话我.
记得结果是逐个判断最快
{
if ( isEncodeValue ) keyValue = HttpUtility.UrlEncode(keyValue); if (queryString[key]==null )
{
// new key, add it
queryString.Add(key, keyValue);
}
else
{
// key exist, update the value
queryString.Set(key, keyValue);
}
}
public static string GetRedirectUrl(NameValueCollection queryString)
{
string redirectUrl = string.Empty;
int counter = 0;
foreach(string key in queryString.Keys)
{
redirectUrl += string.Format("{0}{1}={2}", (counter>0)?"&":"", key, queryString[key]);
counter++;
}
return redirectUrl;
}
http://blog.csdn.net/zhzuo/archive/2004/10/28/156647.aspx
asp.net中显示DataGrid控件列序号的几种方法
http://blog.csdn.net/zhzuo/archive/2004/09/10/100882.aspx
public string EncodeBase64(string code_type,string code)
{
string encode = "";
byte[] bytes = Encoding.GetEncoding(code_type).GetBytes(code);
try
{
encode = Convert.ToBase64String(bytes);
}
catch
{
encode = code;
}
return encode;
}
Base64解码
public string DecodeBase64(string code_type,string code)
{
string decode = "";
byte[] bytes = Convert.FromBase64String(code);
try
{
decode = Encoding.GetEncoding(code_type).GetString(bytes);
}
catch
{
decode = code;
}
return decode;
}
保证一个类仅有一个实例,并提供一个访问它的全局访问点。
适用性:
当类只能有一个实例而且客户可以从一个众所周知的访问点访问它时。
当这个唯一实例应该是通过子类化可扩展的,并且客户应该无需更改代码就能使用一个扩展的实例时。 namespace Singleton_DesignPattern
{
using System; class Singleton
{
private static Singleton _instance;
public static Singleton Instance()
{
if (_instance == null)
_instance = new Singleton();
return _instance;
}
protected Singleton(){} // Just to prove only a single instance exists
private int x = 0;
public void SetX(int newVal) {x = newVal;}
public int GetX(){return x;}
} /// <summary>
/// Summary description for Client.
/// </summary>
public class Client
{
public static int Main(string[] args)
{
int val;
// can't call new, because constructor is protected
Singleton FirstSingleton = Singleton.Instance();
Singleton SecondSingleton = Singleton.Instance(); // Now we have two variables, but both should refer to the same object
// Let's prove this, by setting a value using one variable, and
// (hopefully!) retrieving the same value using the second variable
FirstSingleton.SetX(4);
Console.WriteLine("Using first variable for singleton, set x to 4"); val = SecondSingleton.GetX();
Console.WriteLine("Using second variable for singleton, value retrieved = {0}", val);
return 0;
}
}
}
我的:cuijiazhao.mblogger.cn