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值啊?

解决方案 »

  1.   

    这个 c#藐视我还没学过;但是如果是php 我知道需要将 session 通道打开才能存东西哦
      

  2.   

    sesion在服务器端? 什么意思? 我想问的是我在登陆页面(login1.aspx.cs) 里怎么保存session["name"]啊?  
      

  3.   

    Session["name"] = SESSION的值;
    这样不就可以了吗。到另一个页面直接session["name"]引用它的值!
      

  4.   

    html代码里能接收session["name"] 然后做判断么?
      

  5.   

    session变量是直接赋值的。要在html里出现,只能是输出session变量里的值。
    另外,asp的session变量是要在服务器上设置的。