要在VS2005 下开发的
要源代码。谢谢各位了!!
要源代码。谢谢各位了!!
解决方案 »
- 发现SqlDataSource的SelectCommandType如果是存储过程,最好在selecting中赋值?
- 怎么给网页在添加图片的页眉页脚啊
- gridview修改出错
- 使用 URLRewriter 组建可以将 hostname/101.aspx 定向为http://hostname/list.aspx?id=101
- 熟悉.net的高手请进入,我的网站打不开了。求帮忙
- 事务无效,百思不解,高手入内,薄分相赠 -- 佳节快乐
- 敬请帮忙,来者有分!!
- 问一个datagrid 和 css style sheet 的问题
- 简单问题,高分求教:)
- 为什么一个button要点两下才起作用?
- 讨论:为什么要开多线程?
- C#数据绑定问题
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CheckUser.aspx.cs" Inherits="CheckUser" %><html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>无标题页</title>
<style type="text/css">
<!--
#apDiv1 {
position:absolute;
right:20px;
top:5px;
z-index:1;
display:none;
background:#ddd;
padding:5px 0 0 5px;
}
-->
</style>
<script type ="text/jscript">
function checkusername(obj)
{
var xmlhttp;
//IE浏览器
if (window.ActiveXObject)
{
try
{
xmlhttp = new ActiveXObject("MSXML2.XMLHTTP");
}
catch(ex)
{
xmlhttp = new ActiveXObject("microsoft.XMLHTTP");
}
}
else if (window.XMLHttpRequest)
{
xmlhttp = new XMLHttpRequest();
}
var url = "CheckUser.aspx?aaa=uuu&name=" + obj.value
+ "&t=" + new Date().getTime();
xmlhttp.open("GET",url,true);
xmlhttp.onreadystatechange = function(){if (xmlhttp.readyState == 1)
{
document.getElementById("apDiv1").style.display="block";
}
if (xmlhttp.readyState == 4)
{
document.getElementById("apDiv1").style.display="none";
}
if (xmlhttp.readyState == 4 &&
xmlhttp.status == 200)
{
if(xmlhttp.responseText == "1")
{
document.getElementById("msg").innerHTML =
"用户名已经被注册了";
}else
{
document.getElementById("msg").innerHTML =
"用户名可以使用";
}
}
}
xmlhttp.send(null); }
</script>
</head>
<body>
<div id="apDiv1">正在加载中,请稍候</div>
用户<input id="username" onblur="checkusername(this);" type="text" /><span id="msg" style="color:#F00;"></span>
<br />
用户密码<input id="Password1" type="password" /><br />
用户邮箱<input id="Text1" type="text" />
<br />
<input id="Button1" type="button" value="注册" /><br /></body>
</html>using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;public partial class CheckUser : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(5000);
if (Request.QueryString["aaa"] == "uuu")
{
if (Request.QueryString["name"] == "test")
Response.Write("1");
else
Response.Write("0");
Response.End();
}
}
}
+ "&t=" + new Date().getTime();
xmlhttp.open("GET",url,true); 提交给自身页面好像不行啊,好像要提交给另一个页面才可以吧????
+ "&t=" + new Date().getTime();
xmlhttp.open("GET",url,true);
提交给自身页面不行,用alert()弹出来的是整个网页的源码啊。
怎么解决啊???
原始
http://blog.csdn.net/greatverve/archive/2008/11/07/3247056.aspx
微软
http://blog.csdn.net/greatverve/archive/2008/12/09/3483268.aspx
AjaxPro.dll
对吧??
把url 该为var url = "Default.aspx.cs?aaa=uuu&name=" + obj.value
+ "&t=" + new Date().getTime();
就好
把 if (Request.QueryString["aaa"] == "uuu") {
Response.End();
}
删了就错了请加上 就OK了
<head runat="server">
<title>无标题页</title>
<script type="text/javascript">
var xmlHttp;
function createXMLHttpRequest()
{
if(window.ActiveXObject)
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
else if(window.XMLHttpRequest)
xmlHttp=new XMLHttpRequest();
}
function test(butId)
{
createXMLHttpRequest();
xmlHttp.open("get","Default.aspx?butId="+butId+"&date="+new Date().getTime(),true);
xmlHttp.onreadystatechange=changeTest; //
xmlHttp.send(null);
}
function changeTest()
{
if(xmlHttp.readyState==4)
{
if(xmlHttp.status==200)
{
var but=xmlHttp.responseText;
alert(but);
}
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<button onclick="test(this.id)" id="but1"> but1 </button>
</form>
</body>
</html>后台:using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string butid=Request.QueryString["butId"]+"";
if(butid=="but1")
Response.Write("dddddddd");
}
}我自己的,点击按钮把整个网页的源代码都弹出来了。????
Response.End();
它同时弹出1和2,奇怪????