ASP.Net学习笔记008--ASP.Net揭秘之Input版自增补充说明
来源:互联网 发布:淘宝服务站加盟 编辑:程序博客网 时间:2024/06/13 00:38
以前写的课程都没有附上源码,很抱歉!
ASP.Net学习笔记007ASP.Net Input版自增.zip
http://credream.7958.com/down_20155694.html
1.常见错误:把html设置成了启动页
2.非表单元素无法把表单的值,传递给服务器端,即使是表单元素也只能传递value值,对于其他值比如颜色,大小等,都需要使用隐藏字段,才能传递,这就是asp.net中的viewState
的实现原理
-----------------------------------
上节课代码:
IncValue.htm
<!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="IncValue.ashx">
<input type="hidden" name="ispostback" value="true" />
<!--
<input type="submit" value="自增" />
type="button"的时候是不能提交的,如果想提交需要
-->
<input type="text" name="number" value="@value" />
<input type="button" value="自增" onclick ="document.getElementById('From1').submit()" />
</form>
</body>
</html>
-----------------------------------
IncValue.ashx还是上节课的,没有变
<%@ WebHandler Language="C#" Class="IncValue" %>
using System;
using System.Web;
public class IncValue : IHttpHandler {
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/html";
string ispostback = context.Request["ispostback"];
string number = context.Request["number"];
//通过表单提交的都是string类型的
if (ispostback == "true")//说明点击了也没的自增按钮
{
int i = Convert.ToInt32(number);
i++;
number = i.ToString();
}
else {//第一次进入,值为0
number = "0";
}
//context.Response.Write(number);
string fullpath = context.Server.MapPath("IncValue.htm");
string content = System.IO.File.ReadAllText(fullpath);
content= content.Replace("@value", number);
context.Response.Write(content);
//context.Response.Write("你好");
}
public bool IsReusable {
get {
return false;
}
}
}
-------------------------------------------------------------------
0 0
- ASP.Net学习笔记008--ASP.Net揭秘之Input版自增补充说明
- ASP.Net学习笔记011--ASP.Net揭秘之div版本自增
- ASP.Net学习笔记007--ASP.Net Input版自增
- ASP.Net学习笔记005--ASP.Net的IsPostBack揭秘
- asp.net之学习笔记
- 学习ASP.NET MVC5框架揭秘笔记-传统MVC模式
- 学习ASP.NET MVC5框架揭秘笔记-自治视图
- 学习ASP.NET MVC5框架揭秘笔记-什么是MVC模式
- 学习ASP.NET MVC5框架揭秘笔记目录
- 学习ASP.NET MVC5框架揭秘笔记-MVC的变体
- 学习ASP.NET MVC5框架揭秘笔记-MVP
- 学习ASP.NET MVC5框架揭秘笔记-PV与SC
- 学习ASP.NET MVC5框架揭秘笔记-Model2
- 学习ASP.NET MVC5框架揭秘笔记-ASP.NET MVC与Model2
- 学习ASP.NET MVC5框架揭秘笔记-IIS/ASP.NET管道(一)
- 学习ASP.NET MVC5框架揭秘笔记-IIS/ASP.NET管道(二)
- 学习ASP.NET MVC5框架揭秘笔记-IIS/ASP.NET管道(三)
- 学习ASP.NET MVC5框架揭秘笔记-ASP.NET MVC是如何运行的(一)
- JAVA使用http发送post或get请求实例
- Swift 3.0 学习笔记-5-函数
- linux初学 unit2 练习
- 树莓派上安装turtlebot
- nginx源码分析—处理继承的sockets
- ASP.Net学习笔记008--ASP.Net揭秘之Input版自增补充说明
- 蓝桥杯2013年第四届决赛C_C++程序设计本科B组
- Module类
- Ubuntu1404+anconda2+python2.7 Tensorflow1.0安装
- 蓝桥杯:高精度算法
- Apache CXF前端应用(Frontend)
- 方法重载和方法覆盖的区别
- 每日一练之Palindrome Number【LeetCode No.9】—判断是否为回文数
- mysql You can't specify target table for update in FROM clause异常问题.