数据分页一直以来是比较头疼的问题,不少的分页控件也随之产生。但是我用过的几个控件,本身都要执行SQL,对存储过程支持不好,为了方便,特别写了个通用分页类,利用PagedDataSource来实现DataGrid,DataList,Repeater的分页。
完成上一页,下一页,最后一页,最前一页,总页数,当前页数,跳转这些基本的功能。
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace as.Netpager
{
///
/// .Netpager-本类提供datagrid,datalist,repeater的通用分页---jierry 04-7-19
///
public class.Netpager: System.Web.UI.Page
{
private System.Web.UI.WebControls.DataGrid datagrid=null;
private System.Web.UI.WebControls.DataList datalist=null;
private System.Web.UI.WebControls.Repeater repeater=null;
private System.Web.UI.WebControls.HyperLink lnknext;
private System.Web.UI.WebControls.H ......
数据分页一直以来是比较头疼的问题,不少的分页控件也随之产生。但是我用过的几个控件,本身都要执行SQL,对存储过程支持不好,为了方便,特别写了个通用分页类,利用PagedDataSource来实现DataGrid,DataList,Repeater的分页。
完成上一页,下一页,最后一页,最前一页,总页数,当前页数,跳转这些基本的功能。
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace as.Netpager
{
///
/// .Netpager-本类提供datagrid,datalist,repeater的通用分页---jierry 04-7-19
///
public class.Netpager: System.Web.UI.Page
{
private System.Web.UI.WebControls.DataGrid datagrid=null;
private System.Web.UI.WebControls.DataList datalist=null;
private System.Web.UI.WebControls.Repeater repeater=null;
private System.Web.UI.WebControls.HyperLink lnknext;
private System.Web.UI.WebControls.H ......
应用程序,窗体里拖放一个TreeView控件,想把数据库里的数据在这个控件里显示出来
TREEVIEW控件是Winfrom窗体里的 不是ASP.NET里的TREEVIEW
代码如下:
CREATE TABLE CateTable (
[ID] [int] IDENTITY (1, 1) NOT NULL ,
[CateName] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[RootID] [int] NOT NULL ,
[ParentID] [int] NOT NULL
)
GO
存储过程:
CREATE PROCEDURE CateTable_GetList AS
BEGIN
Select
CateID,
CateName,
RootID,
ParentID
from
&n ......
最近访问了建行网站时 https://ibsbjstar.ccb.com.cn/V5/index.html#,(其实在oblog,http://www.oblog.cn也采用了类似的技巧,不过方法不同罢了)
可以发现,当选择不同的文本框,可以出现不同的颜色,要完成这个功能很简单,但是如果有很多类似的功能,如果一个个设置控件样式显然很累,一个简单的处理方法写一个方法让系统执行就可以了,看如下代码:
class BasePage:Page
{
public static void SetInputControlsHighlight(Control container, string className, bool onlyTextBoxes)
{
foreach (Control ctl in container.Controls)
{
if ((onlyTextBoxes && ctl is TextBox) ctl is TextBox ctl is DropDownList
ctl is ListBox ctl is CheckBox ctl is RadioButton
ctl is RadioButtonList ctl is CheckBoxList)
{
WebControl wctl = ctl as WebControl;
wctl.Attributes.Add("onfocus", string.Format("this.className = '{0}';", className));
wctl.Attributes.Add("onblur", "this.className = '';");
}
else
{
if (ctl.Controls.Count > 0)
SetInputControlsHighlight(ctl, className, onlyT ......
支付宝的接口调用很不方便,刚做好一个封装,实现了虚拟交易和实物交易。
解决方案中有三个项目以及NDoc生成的文档,简单的序列图:CommonAliPay,封装的支付宝接口。
TestAli,asp.net的测试项目
TestCommonAliPay,Nunit的测试项目。
调用方法:
1、引入CommonAliPay.dll
2、实现支付宝服务接口的方法调用方式:
AliPay ap = new AliPay();
string key = "";//填写自己的key
string partner = "";//填写自己的Partner
StandardGoods bp = new StandardGoods("trade_create_by_buyer", partner, key, "MD5", "卡2", Guid.NewGuid().ToString(), 2.551m, 1, "hao_ding2000@yahoo.com.cn", "hao_ding2000@yahoo.com.cn"
, "EMS", 25.00m, "BUYER_PAY","1");
bp.Notify_Url = "http://203.86.79.185/ali/notify.aspx";
ap.CreateStandardTrade("https://www.alipay.com/cooperate/gatewa ......
原文:刘武|asp.net中cookie的处理
使用中发现用Request.Cookies.Remove()无法删除cookie,google了一下发现一般是通过将过期时间设置成过去的时间来完成删除的。顺便整理下cookie的操作:
一 创建
1 单值的创建
C#-Code:
HttpCookie hc = new HttpCookie("Value");
hc.Value = "value";
Response.AppendCookie(hc);
2 多值的创建
C#-Code:
HttpCookie hc = new HttpCookie("Value");
hc["Value1"] = "value1";
hc["Value2"] = "value2;
Response.AppendCookie(hc);
二 读取
1 单值的读取
C#-Code:
string value = Request.Cookies["Value"].Value;
2 多值的读取
C#-Code:
string value1 = Request.Cookies["Value"]["Value1"].ToString();
string value2 = Request.Cookies["Value"]["Value2"].ToString();
三 删除
C#-Code:
HttpCookie hc = Request.Cookies["Value"];
hc.Expires = DateTime.Now.AddDays(-1);
//下面这句一定要加上,否则无法删除
Response.AppendCookie(hc);
......
关键在上传的使用用到了upload.aspx,而这个页面默认的编码统一为utf-8,所以我们要给它改变一下。在你的web.config中增加此字段
<location path="fckeditor/editor/filemanager/connectors/aspx/upload.aspx">
<system.web>
<globalization requestEncoding="utf-8" responseEncoding="gb2312"/>
</system.web>
</location>
注意,你的web.Config中不要指定全局 <globlization>如:
<globalization requestEncoding="gb2312" responseEncoding="gb2312" culture="zh-CN" uiCulture="zh-CN"/>
如果这样,你指定的其他路径<location>将失效,切忌!!!! ......