HTML页和ashx页之间的关联
来源:互联网 发布:知乎注册要用手机 编辑:程序博客网 时间:2024/06/05 17:44
html页
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<form action="hello.ashx">
<input type="text" name="username" value="@value"/>
<input type="submit" value="提交" />
<input type="hidden" name="ispostback" value="true" /> <!--隐藏字段-->
@message <!--充当占位符了。。-->
</form>
</body>
</html>
ashx页
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;
namespace _2012._9._17
{
/// <summary>
/// Handler1 的摘要说明
/// </summary>
public class Handler1 : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{ //111111111111111111111111111111111111111111111111111111111
string name = context.Request["username"]; //Request是取得 但要依靠html中的控件用name属性给它命名
context.Response.ContentType = "text/html";//此处要将plain改为html;
context.Response.Write(name); //Response 响应
context.Response.Write(":Hello World");
//22222222222222222222222222222222222222222222222222222222
string path=context.Server.MapPath("hello.htm"); //获取html页的地址
string aaa= File.ReadAllText(path); //将html页的内容写出来直接在ashx文件中显示
//context.Response.Write(aaa);
string ispostback = context.Request["ispostback"]; //获取隐藏字段的值
//if (ispostback == "true") //根据隐藏字段的value来判断是否提交过
//{
// context.Response.Write("提交进入");
//}
//else {
// context.Response.Write("直接进入");
//}
//33333333333333333333333333333333333333333333333333333333
string username = context.Request["username"];
string message = "";
if (ispostback == "true")
{
context.Response.Write("提交进入");
message = username + "hello";
}
else {
context.Response.Write("直接进入");
username = "";
message = "Hello World";
}
aaa=aaa.Replace("@value", username); //将占位符替换
aaa = aaa.Replace("@message", message);
context.Response.Write(aaa);
//444444444444444444444444444444444444444444444444444444444
//把hello.htm的内容输出
//string username= context.Request["UserName"];
// if(string.IsNullOrEmpty(username)) // IsNullOrEmpty是判断是否为空的方法。。
// {
// context.Response.Write("直接进入");
// }
// else
// {
// context.Response.Write("提交进入");
// }
}
public bool IsReusable
{
get
{
return false;
}
}
}
}
- HTML页和ashx页之间的关联
- HTML页和ashx之间关系的一点小应用
- .ashx内部读取和设置html元件的内容
- 配置JRE和Mozilla之间的关联
- 原生与html之间进行简单的关联
- linux和linux和html的关联
- c++和html和struts2的关联
- html和framework和c++的关联
- jetty和html和tcpdump的关联
- commonio和tomcat和html的关联
- c#和html和ruby的关联
- html和ssh和groovy的关联
- python和android和html的关联
- wireshark和spring和html的关联
- ant和html和wireshark的关联
- html和tcp和jak的关联
- velocity和html和sqlplus的关联
- ruby和html和sqlserver的关联
- hadoop学习笔记1--centos6.2 64位 最小化(minimal)安装配置
- PHP 杂谈《重构-改善既有代码的设计》之二 对象之间搬移特性
- actioncolumn里面设置操作列显示和隐藏
- 快速幂模板(整数+矩阵)
- 搭建 Http Dynamic Streaming 点播/直播服务器
- HTML页和ashx页之间的关联
- 修改代码实现常见视频的自动播放
- 排序算法整理
- Linux时间子系统之三:时间的维护者:timekeeper
- 晶体管参数在实际使用中的意义
- 面试题整理(三)
- 用 Windows server 2003 组策略部署 Windows 防火墙
- 编程之美之 饮料供货 之 动态规划算法和备忘录算法实现
- python中read() readline()以及readlines()用法