关于需要用到的JS文件请到地址:http://d.download.csdn.net/down/2387457/taomanman免费下载;
下面介绍其使用方法:
第一步:
到我提供的地址下载JS文件,并解压到项目某个目录下,你自己定啦。
第二步:
在需要用到时间控件的aspx页面中添加该JS文件中的WdatePicker.js文件。
如<script src="../JS/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
接着就是添加两个文本框,这个时间控件是利用TextBox进行改造而成的,添加代码如下:
<asp:panel id="Panel1" style="width: 100%" runat="server" >
起始时间<input id="tbStartTime" type="text" runat="server" style="width: 102px" />
截止时间<input id="tbEndTime" type="text" runat="server" style="width: 102px" />
<asp:Button ID="btnQuery" runat="server" Text="查询" onclick="btnQuery_Click" />
</asp:panel>
第三步:
在后台aspx.cs文件中添加如下代码:
protected void Page_Load(object sender, EventArgs e)
......
这两天看《道不远人-----深入解析ASP.NET2.0控件开发》这本书,看完第二章内容后,想总结下“设置自定义ASP.NET服务器控件TagPrefix的几种方法”,以便以后查阅,以下面code编写的控件为例,由于重点不是控件编写,所以写了个非常简单的控件,姑且叫它EmailInput
Code
1using System;
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.Text;
5using System.Web;
6using System.Web.UI;
7using System.Web.UI.WebControls;
8
9namespace ServerControl
10{
11 [ToolboxData("<{0}:EmailInput runat=server></{0}:EmailInput>")]
12 public class EmailInput : CompositeControl
13 {
14 protected RegularExpressionValidator _regValidator;
15 protected RequiredFieldValidator&n ......
一、使用QueryString参数
QueryString将传递的值显示在浏览器的地址栏中,是一种非常简单也使用比较多的传值方式。
如果传递一个或多个安全性要求不高或是结构简单的数值时,可以使用这个方法
/// <summary>
/// 使用QueryString变量
/// </summary>
/// <param name="param1"></param>
/// <param name="param2"></param>
//sourcePage
Response.Redirect("target.aspx?param1 = hello¶m2 = hi");
//targetPage
string str1 = Request.QueryString["param1"];
string str2 = Request.QueryString["param2"];
二、使用cookie对象变量
cookie存放在客户端中
//setting cookie
HttpCookie cookie_name = new HttpCookie("name");
cookie_name.value = txtName.Text.Trim();
Response.AppendCookie (cookie_name);
//get cookie
string name = Request.Cookie["name"].Value.ToString();
三、使用session变量
session存放在服务器中,如果连接超时等情况,有可能会发生数据丢失
//setting session
Session["name"] = "hello";
//get session
string name = Sessio ......
/// <summary>
/// 根据指定参数返回BitMap对象
/// 引用如下:
/// using System.Drawing;
/// 调用例子如下:
/// eg1、保存为图象文件为
/// Bitmap srBmp = srBitmap(srs);
/// srBmp.Save(Directory.GetCurrentDirectory() + "\\srs.gif", System.Drawing.Imaging.ImageFormat.Gif);
/// srBmp.Dispose();
/// eg2。网页中调用方式如下
/// Bitmap srBmp = srBitmap(srs);
/// ......
/// <summary>
/// 根据指定参数返回BitMap对象
/// 引用如下:
/// using System.Drawing;
/// 调用例子如下:
/// eg1、保存为图象文件为
/// Bitmap srBmp = srBitmap(srs);
/// srBmp.Save(Directory.GetCurrentDirectory() + "\\srs.gif", System.Drawing.Imaging.ImageFormat.Gif);
/// srBmp.Dispose();
/// eg2。网页中调用方式如下
/// Bitmap srBmp = srBitmap(srs);
/// ......
HttpContext.Current.Request.Url.ToString() 并不可靠。
如果当前URL为
http://localhost/search.aspx?user=http://csharp.xdowns.com&tag=%BC%BC%CA%F5
通过HttpContext.Current.Request.Url.ToString()获取到的却是
http://localhost/search.aspxuser=http://csharp.xdowns.com&tag=¼¼Êõ
正确的方法是:HttpContext.Current.Request.Url.PathAndQuery
1、通过ASP.NET获取
如果测试的url地址是http://www.test.com/testweb/default.aspx, 结果如下:
Request.ApplicationPath: /testweb
Request.CurrentExecutionFilePath: /testweb/default.aspx
Request.FilePath: /testweb/default.aspx
Request.Path:   ......
学习ASP.NET中的Application、Session、Cookie
1.Application建立的变量,在系统内部任何地方都可以访问,通常网站地访问统计可能会用的较多。如果要用到Application首先在VS2005中建立一个global.asa文件。例如我们要写一个网站访问数量的统计的话,在global.asa中先声明变量iCount。如下所示:
protected void Application_Start(object sender, EventArgs e)
{
Application["iCount"] = 0;
}
然后在Page_Load事件中打入以下代码:
protected void Page_Load(object sender, EventArgs e)
{
Application["iCount"] = (int)Application["iCount"] + 1;
Response.Write(Application["iCount"]);
&n ......