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值啊?
解决方案 »
- 关于while循环里为什么数据只显示最后一条呢?
- 大家好,php显示flash的问题,firefox和google可以显示,ie8不显示
- mysql 生成查询结果数组的问题
- unset 静态变量问题
- 采用UTF-8,但是取回值显示乱码怎么解决?
- 怎样打印php返回内容?
- 关于php4的session的问题!!
- 為什么我的瀏覽器不能打開.PHP文件?
- 作了个上传文件的简单脚本 可是老师不能正确显示文件名~~~
- 为什么调用ftp_connect()时会显示"Call to undefined function: ftp_connect()…"?请指教。
- php有没有类似asmx?wsdl这样子的接口技术?
- 为什么我到aspx.cs页面的时候接收不到session,提示data:未将对象引用设置到对象的实例。
这样不就可以了吗。到另一个页面直接session["name"]引用它的值!
另外,asp的session变量是要在服务器上设置的。