ASP.NET(C#)返回上一页(后退)代码
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ViewState["BackUrl"] = Request.UrlReferrer.ToString();
}
}
/// <summary>
/// 返回按钮点击事件
/// </summary>
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect(ViewState["BackUrl"].ToString());
}
另一种方法
在C# Web程序中,如为页面按钮写返回上一页代码
this.RegisterClientScriptBlock("E", "<script language=javascript>history.go(-2);</script>");
其中,history.go(-2),要写为-2,因在按钮事件触发前,已刷新一次页面,所以应是-2。
Response.Write("<script language=javascript>history.go(-2);</script>");
此处也要写为“-2”。跟直接写脚本的有所不同。
相关文档:
public struct RECT
{
public int left;
public int Top;
public int Right;
public int Bottom;
}
public static bool CenterMouseOn(int hwnd)
{
......
C#格式化数值结果表
字符
说明
示例
输出
C
货币
string.Format("{0:C3}", 2)
$2.000
D
十进制
string.Format("{0:D3}", 2)
002
E
科学计数法
1.20E+001
1.20E+001
G
常规
string.Format("{0:G}", 2)
2
N
用分号隔开的数字
string.Format("{0:N}", 250000)
250,000.00
X
十六进制
string.Forma ......
在学习过程中发现如果要上传的照片很大的话,速度会很慢,所以采用了在上传照片时同时上传缩略图的方式,这样就可以既不影响多个图片的浏览,又不影响查看具体的图片。
需要用到的命名空间:
using System.Drawing;
using System.IO;
using System.Drawing.Imaging;
#region 保存上传文件,方法名:UploadSave(string ......
ASP.NET 2.0
文件1: Deafault.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&l ......