Easyui登陆页面制作

王朝学院·作者佚名  2016-08-27  
宽屏版  字体: 小 | 中 | 大 | 超大  

一、登陆页面HTML

<%@ Page Language="C#"AutoEventWireup="true"CodeBehind="WebForm1.aspx.cs"Inherits="Webapplication1.EasyUITest.WebForm1"%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><headrunat="server"><title>Login</title><scriptsrc="../Scripts/jquery-1.6.min.js"type="text/javascript"></script><scriptsrc="../Scripts/jquery.easyui.min.js"type="text/Javascript"></script><linkhref="../Scripts/themes/icon.CSS"rel="stylesheet"type="text/css"/><linkhref="../Scripts/themes/default/easyui.css"rel="stylesheet"type="text/css"/><scripttype="text/javascript">$(function() {

$("#win").window({

title:"Login",

width:300,

height:200,

collapsible:false,

minimizable:false,

maximizable:false,

closable:false,

closed:false,

draggable:false,

resizable:false,

modal:true});

});functionlogin() {varname=$("#txt_name").val();varPSD=$("#txt_psd").val();

$.Ajax({

type:"POST",

dataType:"json",

url:"Service/login.ashx",

data: { Method:"Login"},

success:function(data) {

$.messager.alert("消息", data,"info");

},

error:function() {

$.messager.alert("消息","错误!","info");

}

});

}</script></head><body><formid="form1"runat="server"><divid="win"class="easyui-window"><table><tr><td>Name:</td><td><inputid="txt_name"type="text"/></td></tr><tr><td>PassWord:</td><td><inputid="txt_psd"type="text"/></td></tr><tr><td><ahref="#"class="easyui-linkbutton"iconcls="icon-ok"onclick="login()">Login</a></td><td><ahref="#"class="easyui-linkbutton"iconcls="icon-cancel">Cancel</a></td></tr></table></div></form></body></html>

二、一般处理程序

usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Web;usingSystem.Reflection;usingSystem.Web.sessionState;usingNewtonsoft.Json;namespaceWebApplication1.EasyUITest.Service

{///<summary>///login 的摘要说明///</summary>publicclasslogin : IHttpHandler, IRequiresSessionState

{

HttPRequest Request;

HttpResponse Response;

HttpSessionState Session;

HttpServerUtility Server;//HttpCookie Cookie;publicvoidProcessRequest(HttpContext context)

{//不让浏览器缓存context.Response.Buffer =true;

context.Response.ExpiresAbsolute= DateTime.Now.AddDays(-1);

context.Response.AddHeader("pragma","no-cache");

context.Response.AddHeader("cache-control","");

context.Response.CacheControl="no-cache";

context.Response.ContentType="text/plain";

Request=context.Request;

Response=context.Response;

Session=context.Session;

Server=context.Server;stringmethod = Request["Method"].ToString();

MethodInfo methodInfo=this.GetType().GetMethod(method);

methodInfo.Invoke(this,null);

}publicvoidLogin()

{

Response.Write(JsonConvert.SerializeObject(DateTime.Now.ToString()));

}

[Serializable]publicclassInfomation

{publicstringid {get;set; }publicstringmsg {get;set; }

}publicboolIsReusable

{get{returnfalse;

}

}

}

}

三、Index页面

<%@ Page Language="C#"AutoEventWireup="true"CodeBehind="index.aspx.cs"Inherits="WebApplication1.EasyUITest.index"%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><headrunat="server"><title></title><scriptsrc="../Scripts/jquery-1.6.2.min.js"type="text/javascript"></script><scriptsrc="../Scripts/jquery.easyui.min.js"type="text/javascript"></script><linkhref="../Scripts/themes/default/easyui.css"rel="stylesheet"type="text/css"/><linkhref="../Scripts/themes/icon.css"rel="stylesheet"type="text/css"/><scripttype="text/javascript">$(function() {

$("#tt").tree({

checkbox:false,

url:"Service/index.ashx?Method=GetTreeData&id=0",

onBeforeExpand:function(node, param) {

$(this).tree("options").url="Service/index.ashx?Method=GetTreeData&id="+node.id;

},

onClick:function(node) {

$("#contentPage").attr("src", node.attributes);

}

});

});functionOpen() {

$("#contentPage").attr("src","WebForm1.aspx");

}</script></head><bodyclass="easyui-layout"><divregion="north"style="height: 100px;"></div><divregion="west"style="width: 200px;"title="west"split="true"><ulid="tt"></ul></div><divid="divCenter"region="center"title="center"style="padding: 5px; background: #eee;"><iframeid="contentPage"width="100%"height="100%"frameborder="0"marginheight="0"marginwidth="0"></iframe></div></body></html>

四、Index一般处理程序

usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Web;usingSystem.Web.SessionState;usingSystem.Reflection;usingSystem.Data.SqlClient;usingSystem.Configuration;usingSystem.Data;usingSystem.Text;namespaceWebApplication1.EasyUITest.Service

{///<summary>///index 的摘要说明///</summary>publicclassindex : IHttpHandler

{

HttpRequest Request;

HttpResponse Response;

HttpServerUtility Server;

HttpSessionState Session;publicreadonlystringconnectionString = ConfigurationManager.ConnectionStrings["BookConnectionString"].ToString();publicvoidProcessRequest(HttpContext context)

{

context.Response.Buffer=true;

context.Response.ExpiresAbsolute= DateTime.Now.AddDays(-1);

context.Response.AddHeader("pragma","no-cache");

context.Response.AddHeader("cache-control","");

context.Response.CacheControl="no-cache";

context.Response.ContentType="text/plain";

Request=context.Request;

Response=context.Response;

Session=context.Session;

Server=context.Server;stringmethod = Request["Method"].ToString();

MethodInfo methodInfo=this.GetType().GetMethod(method);

methodInfo.Invoke(this,null);

}publicvoidGetTreeData()

{stringid = Request.QueryString["id"].ToString();stringsqlStr ="SELECT * FROM dbo.tree where parentid="+id;

DataSet ds=newDataSet();using(SqlConnection conn =newSqlConnection(connectionString))

{using(SqlDataAdapter da =newSqlDataAdapter(sqlStr, conn))

{

da.Fill(ds);

}

}

StringBuilder sb=newStringBuilder();

sb.Append("[");foreach(DataRow rinds.Tables[0].Rows)

{

sb.Append("{");

sb.AppendFormat("\"id\": \"{0}\", \"text\": \"{1}\", \"state\": \"closed\",\"attributes\":\"{2}\"", r["id"], r["name"], r["url"]);

sb.Append("},");

}

sb= sb.Remove(sb.Length -1,1);

sb.Append("]");

Response.Write(sb.ToString());

}publicboolIsReusable

{get{returnfalse;

}

}

}

}

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有