Archive

Archive for the ‘Web’ Category

JS Calendar Date Picker 日期选择、日历、不连续日期

July 5th, 2010 Tony hu No comments

这两天一直为一件事苦恼,怎么使用日期选择器来选取几个不连续的日期,今天终于找到了。

http://nogray.com/calendar.php 【JavaScript Calendar Component】

当然,如果你有其它需要,这里有30个很Cool的Calendar Date Picker

http://www.edesignerz.net/tips-a-tricks/16700-show-time-30-jquery-calendar-date-picker-plugins

试一下!

Categories: Tools Tags:

GridView 排序 分页 编辑 删除 更新 模板 综合使用

June 13th, 2010 Tony hu No comments

这是我最近在做一个项目,我尽量全部手写代码。现在将CS文件贴分来分享一下,作一个备忘吧!

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace Capsugel.Web
{
public partial class Customers : System.Web.UI.Page
{
//使用DataView,排序的时候使用到
DataView dv = new DataView();

protected void Page_Load(object sender, EventArgs e)
{
//第一次加载页面
if (!IsPostBack)
{
bind();
}
}

protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
//测试 Ajax
//System.Threading.Thread.Sleep(1000);
GridView1.PageIndex = e.NewPageIndex;
//重新绑定一次
bind();
}

///
/// 绑定GridView
///
void bind()
{
Capsugel.BLL.Customer bll = new BLL.Customer();
//根据TextBox中的关键词,显示数据
DataTable dt = bll.GetList_ByName(TextBox1.Text.Trim()).Tables[0];
if (ViewState["sortExpr"] != null)
{
dv = new DataView(dt);
dv.Sort = (string)ViewState["sortExpr"] + ” ” + ViewState["sortingOrder"].ToString();
}
else
{
dv = dt.DefaultView;
}
GridView1.DataSource = dv;
GridView1.DataBind();
}

protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
int idx = 0;
string Uid = “”;
BLL.Customer bll = new BLL.Customer();

if (e.CommandName == “myedit”)
{
//得到当前行的索引号,确定要将哪一行开启编辑状态,
//如果是第二行的第一个,那应该是 0,所以才有了下面的公式
idx = Convert.ToInt32(e.CommandArgument)-GridView1.PageIndex * GridView1.PageSize;
GridView1.EditIndex = idx;
}
else if (e.CommandName == “myupdate”)
{
idx = Convert.ToInt32(e.CommandArgument) – GridView1.PageIndex * GridView1.PageSize;
Uid = GridView1.DataKeys[idx].Values[0].ToString();
//得到编辑框中的值
string uname = ((TextBox)GridView1.Rows[idx].FindControl(“TextBox1″)).Text;
string custid = ((TextBox)GridView1.Rows[idx].FindControl(“TextBox2″)).Text;
string userid = ((TextBox)GridView1.Rows[idx].FindControl(“TextBox3″)).Text;
bool check = ((CheckBox)GridView1.Rows[idx].FindControl(“CheckBox1″)).Checked;
//对像模型
Model.Customer m = new Model.Customer();
m.CID = Convert.ToInt32(Uid);
m.Checked = check;
m.Name = uname;
m.CustID = custid;
m.Uid = userid;
//更新
bll.Update(m);
//取消编辑状态
GridView1.EditIndex = -1;
}
else if (e.CommandName == “mydelete”)
{
idx = Convert.ToInt32(e.CommandArgument) – GridView1.PageIndex * GridView1.PageSize;
Uid = GridView1.DataKeys[idx].Values[0].ToString();
bll.Delete(Convert.ToInt32(Uid));
}
else if (e.CommandName == “mycancel”)
{
GridView1.EditIndex = -1;
}
//最后都要进行重新绑定一次
bind();
}

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
//判断是否是DataRow,以防止鼠标经过Header也有效果
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add(“onmouseover”, “e=this.style.backgroundColor;this.style.backgroundColor=’#BDF9AC’;”);
e.Row.Attributes.Add(“onmouseout”, “this.style.backgroundColor=e;”);
}
}

protected void Button3_Click(object sender, EventArgs e)
{
//POSTBACK
bind();
}

///
/// 处理排序的问题,定义的排序
///
///
///
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
{
//点一次时是desc,第二次是asc
if (ViewState["sortingOrder"] == null)
ViewState["sortingOrder"] = “desc”;
else if (Convert.ToString(ViewState["sortingOrder"]) == “asc”)
ViewState["sortingOrder"] = “desc”;
else if (Convert.ToString(ViewState["sortingOrder"]) == “desc”)
ViewState["sortingOrder"] = “asc”;

ViewState["sortExpr"] = e.SortExpression;
bind();
}

///
/// 显示所有的,只要清空一下TextBox中的值
///
///
///
protected void Button4_Click(object sender, EventArgs e)
{
TextBox1.Text = “”;
bind();
}
}
}

Categories: ASP.net, Web Tags: , , , ,

ASP.NET 4.0 新特性(不完全版)

June 11th, 2010 Tony hu No comments
  • 图表控件
  • SEO优化支持
  • URL Routing
  • Web.Config Transformation

if (!Page.IsPostBack)
{
Page.Title = “在这里可以设置页面的Title”;
Page.MetaDescription = “在这里可以设置页面的Description”;
Page.MetaKeywords = “在这里可以设置页面的keywords,做SEO”;
}

IETester 集IE5.5,IE6,IE7,IE8为一体

March 22nd, 2010 Tony hu No comments

ETester is a free WebBrowser that allows you to have the rendering and javascript engines of IE8, IE7 IE 6 and IE5.5 on Windows 7, Vista and XP, as well as the installed IE in the same process.
New in v0.4.2 : Added developer options to enable/disable browser features !

This is an alpha release, so feel free to post comments/bugs on the IETester forum.
Requirement : Windows 7, Windows Vista or Windows XP with IE7 minimum (Windows XP/IE6 config has some problems and IE8instance do not work under XP without IE7)

Download IETester v0.4.2 (25MB)

Known problems and limitations :

  • The Previous/Next buttons are not working properly
  • Focus is not working properly
  • Java applets are not working
  • Flash is not working on IE6 instance in user mode : A solution is to launch IETester as admin user and Flash will work.
  • CSS Filters are not working correctly in user mode : A solution is to launch IETester as admin user and CSS Filters will work.

以前一直为找一个装有IE6.0的浏览器而苦恼,前端开发人员也为这个劳民伤财。从我自己掌握的数据来看目前IE6.0在中国的占有率为35%到40%之间,所以IE6.0还是需要考虑的,无论Google是否支持。从dbanotes那里我知道了有IETester这个玩意儿,真不错。

Categories: Web Tags:

构建高性能Web站点——读书笔记(1)

March 9th, 2010 Tony hu No comments

数据的网络传输

  • 不同传输介质中信号的传输速度几乎是等于常量(无论是铜线和还是光纤)
  • 带宽是指数据的发送速度。如百兆网卡,是指网卡的最大发送速度为100MBbps,即一秒种最多可以发送100Mb的数据。
Categories: Performance Tags: