asp.net利用jquery的ajax方法来验证登陆的代码
许多程序员在做业务开发时往往会在服务器端做用户信息的验证,有没有考虑过用jquery的ajax方法来验证登陆呢?且效果比在服务器端写代码来验证好的多,页面无刷新即可实现实现登陆验证,代码也简单。
现在下面贴出来的是很简单的用jquery的ajax方法来验证登陆的代码,适合刚接触jquery的朋友学习。
前台页面代码:
<head>
<script src="js/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
userlogin=function(){
$.ajax({
type:"get",
cache:false,
url:"ajaxpage.aspx",
dataType:"json",
data:"username="+$("#txt_username").val()+"&password="+$("#txt_pwd").val(),
success:function(data){
if(data.sta==1)
{
alert(data.info);
}
else
{
alert(data.info);
}
}
})
}
</script>
</head>
<body>
<div>
<table>
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text="用户名:"></asp:Labe
相关文档:
为了能让来自不同文化习惯或使用不同语言作为母语的访客能够阅读我们的网站,则必须为这些读者提供用他们自己的语言查看网页的方法。一种方法是分别用各语言重新创建页面,但这种方法可能需要大量工作量、容易出错并且在更改原始页时很难维护。利用 ASP.NET,可以使创建的页面基于浏览器的首选语言设置或用户显式选择的语言 ......
解决办法:app_code/ 存放一个类 用来截获HTTP
1.代码如下
using System;
using System.IO;
using System.Web;
using System.Text;
using System.Text.RegularExpressions;
/// <summary>
/// Removes whitespace from the webpage.
/// </summary>
public class ViewstateModule : IHttpModule
{
......
ASP.NET打开新页面而不关闭原来的页面
Respose.Write("<script language='javascript'>window.open('"+ url +"');</script>"); (打开简洁窗口):
Respose.Write("<script l ......
1,本例子实现一个Ajax更改数据的例子
如图:
1,新建xml文件;其内容如下:
<?xml version="1.0" encoding="utf-8"?>
<userinfo>
<user>
<id>I</id>
<name>wtq</name>
<password>123456</password>
<phone>0595-8553 ......