aspx代码如下
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="login1.aspx.cs" Inherits="login1" %>
<body><a>
<script type="text/javascript">
function $(id){
return document.getElementById(id);
}
window.onload = function(){ $('username').focus();
$('username').onkeydown = function(){
if(event.keyCode == 13){
$('password').select();
}
}
$('password').onkeydown = function(){
if(event.keyCode == 13){
if(chklg())
window.open('http://localhost/search/search.aspx','found','width=300,height=200')
}
}
} function chklg(){
if($('username').value != "sa"){
alert('用户名输入错误');
$('username').select();
return false;
}
if($('password').value != "sa"){
alert('密码输入错误');
$('password').select();
return false;
}
return true;
} function test(){
if(chklg())
window.open('http://192.168.0.253/search/search.aspx','found','width=300,height=200')
}
</script>
<div style=" border:1px #ddd solid; overflow:hidden;text-align:center; float:center; margin:100px;">
<div style="textalign=center; margin-top:10px; margin-left:auto">
<div><p>用户名:<input type='text'; style="width:160px"; id="username"; name="username"></input></p></div><div id=usr></div>
</div>
<div style="position:relative; margin-top:10px; margin-left:auto;">
<div><p>密码: <input type="password"; style="width:160px"; id='password'; name='password'></input></p></div>
<div id=pwd></div>
</div><div style="margin-top:10px;margin-left:50px;"><input style="width:70px" type="submit"; value="登录" onclick="test()"></input></div>
</div>
</a></body></html>aspx.cs代码如下public partial class login1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Session["name"] = ???;
}
}
}上面aspx.cs代码如何写才能将session写对啊? 就是说跳转到下一个页面(http://localhost/search/search.aspx)的时候,用Session["name"] 得到session值啊?
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="login1.aspx.cs" Inherits="login1" %>
<body><a>
<script type="text/javascript">
function $(id){
return document.getElementById(id);
}
window.onload = function(){ $('username').focus();
$('username').onkeydown = function(){
if(event.keyCode == 13){
$('password').select();
}
}
$('password').onkeydown = function(){
if(event.keyCode == 13){
if(chklg())
window.open('http://localhost/search/search.aspx','found','width=300,height=200')
}
}
} function chklg(){
if($('username').value != "sa"){
alert('用户名输入错误');
$('username').select();
return false;
}
if($('password').value != "sa"){
alert('密码输入错误');
$('password').select();
return false;
}
return true;
} function test(){
if(chklg())
window.open('http://192.168.0.253/search/search.aspx','found','width=300,height=200')
}
</script>
<div style=" border:1px #ddd solid; overflow:hidden;text-align:center; float:center; margin:100px;">
<div style="textalign=center; margin-top:10px; margin-left:auto">
<div><p>用户名:<input type='text'; style="width:160px"; id="username"; name="username"></input></p></div><div id=usr></div>
</div>
<div style="position:relative; margin-top:10px; margin-left:auto;">
<div><p>密码: <input type="password"; style="width:160px"; id='password'; name='password'></input></p></div>
<div id=pwd></div>
</div><div style="margin-top:10px;margin-left:50px;"><input style="width:70px" type="submit"; value="登录" onclick="test()"></input></div>
</div>
</a></body></html>aspx.cs代码如下public partial class login1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Session["name"] = ???;
}
}
}上面aspx.cs代码如何写才能将session写对啊? 就是说跳转到下一个页面(http://localhost/search/search.aspx)的时候,用Session["name"] 得到session值啊?
这样不就可以了吗。到另一个页面直接session["name"]引用它的值!
另外,asp的session变量是要在服务器上设置的。