日期:2014-05-16 浏览次数:20855 次
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>无标题页</title>
<script language="javascript">
function openwin()
{
var url="b.html";
//打开模式窗口,注意模式窗口的样式
var mydata=showModalDialog(url,null,"dialogWidth:300px;dialogHeight:120px;center:yes;help:No;status:Yes;resizable:Yes;edge:sunken");
if(mydata)
alert("您输入的值为:" +mydata.value);
}
</script>
</head>
<body>
<input id="Button1" type="button" value="打开窗口" onclick="openwin()" />
</body>
</html>
------解决方案--------------------
这个用js完全可以实现
楼上的例子就不错
------解决方案--------------------
Ajax Test.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Ajax Test.aspx.cs" Inherits="Ajax_Test" %>
<!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 runat="server">
<title>Ajax Test</title>
<script type ="text/javascript" >
var xmlHttp;
function createXmlHttpRequest()
{
if(window.XMLHttpRequest)
{
xmlHttp=new XMLHttpRequest();
if(xmlHttp.overrideMimeType)
{
xmlHttp.overrideMimeType("text/xml");
}
}
else if(window.ActiveXObject)
{
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
if(!xmlHttp)
{
window.alert("你的浏览器不支持创建XMLhttpRequest对象");
}
return xmlHttp;
}
//创建CheckUserName
function CheckNumber(number)
{
createXmlHttpRequest();
var url="Event.aspx?Number="+number ;
xmlHttp.open("GET",url,true);
xmlHttp.onreadystatechange=CheckNumberResult;
xmlHttp.send(null);
}
//创建用户检测的回调函数
function CheckNumberResult()
{
if(xmlHttp.readyState==4)//服务器响应状态
{
if(xmlHttp.status==200)//代码执行状态
{
if(xmlHttp.responseText=="true")
{
document .getElementById ("txt_Name").value="张三"
}
else
{
document .getElementById ("txt_Name").value="查无此学号!"
}
}
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
请输入学号:<asp:TextBox ID="txt_Number" runat="server" onkeyup="CheckNumber(document.getElementById('txt_Number').value)"></asp:TextBox>(默认学号:001)
<br />
姓名: <asp:TextBox ID="txt_Name" runat="server">