您的位置:首页 > 编程语言 > ASP

一步一步asp.net_ajax学习

2012-05-01 00:38 513 查看
继续ajax,今天的任务是做一个大师信息的页面,大致的静态页面













以前的做法大致是先做一个大师的母板页,然后分成3个页面,分开做,不过那样重用性太低了,数据库语句也不注意性能优化,导致查询非常慢,而且用户体验不好,这次考虑用ajax做,并且优化查询.

要实现的功能:

1.首先ajax加载大师基本信息(包括姓名,性别,出生年月,分类,以及大师头像)

2.然后写三个ajax事件响应大师作品,大师简介,获奖情况,

3.默认进入此页面加载大师简介信息

主要的难点:

1.通过js获取html中的参数,比如一个大师列表页调转过来,传递的参数:MasterInfo.aspx?MasterId=xxxxx

我们需要通过js获取这个MasterId参数

2.ajax加载图片回调

3.最难的地方在大师作品,因为大师有多种类别的作品,我们只能获取每种作品的前8位显示出来,这个涉及到数据库查询优化,以前都是通过两次查询或者嵌套查询,性能非常低,这次需要生成json数据,前台JQuery调用也比较复杂.

实现:

1.js获取html中的参数,到网上看了一下,看到一个蛮不错的脚本,获取html参数

newfunction(settings){
var$separator=settings.separator||'&';
var$spaces=settings.spaces===false?false:true;
var$suffix=settings.suffix===false?'':'[]';
var$prefix=settings.prefix===false?false:true;
var$hash=$prefix?settings.hash===true?"#":"?":"";
var$numbers=settings.numbers===false?false:true;
jQuery.query=newfunction(){
varis=function(o,t){
returno!=undefined&&o!==null&&(!!t?o.constructor==t:true);
};
varparse=function(path){
varm,rx=/\[([^[]*)\]/g,match=/^([^[]+)(\[.*\])?$/.exec(path),base=match[1],tokens=[];
while(m=rx.exec(match[2]))tokens.push(m[1]);
return[base,tokens];
};
varset=function(target,tokens,value){
varo,token=tokens.shift();
if(typeoftarget!='object')target=null;
if(token===""){
if(!target)target=[];
if(is(target,Array)){
target.push(tokens.length==0?value:set(null,tokens.slice(0),value));
}elseif(is(target,Object)){
vari=0;
while(target[i++]!=null);
target[--i]=tokens.length==0?value:set(target[i],tokens.slice(0),value);
}else{
target=[];
target.push(tokens.length==0?value:set(null,tokens.slice(0),value));
}
}elseif(token&&token.match(/^\s*[0-9]+\s*$/)){
varindex=parseInt(token,10);
if(!target)target=[];
target[index]=tokens.length==0?value:set(target[index],tokens.slice(0),value);
}elseif(token){
varindex=token.replace(/^\s*|\s*$/g,"");
if(!target)target={};
if(is(target,Array)){
vartemp={};
for(vari=0;i<target.length;++i){
temp[i]=target[i];
}
target=temp;
}
target[index]=tokens.length==0?value:set(target[index],tokens.slice(0),value);
}else{
returnvalue;
}
returntarget;
};
varqueryObject=function(a){
varself=this;
self.keys={};
if(a.queryObject){
jQuery.each(a.get(),function(key,val){
self.SET(key,val);
});
}else{
jQuery.each(arguments,function(){
varq=""+this;
q=q.replace(/^[?#]/,'');
q=q.replace(/[;&]$/,'');
if($spaces)q=q.replace(/[+]/g,'');
jQuery.each(q.split(/[&;]/),function(){
varkey=decodeURIComponent(this.split('=')[0]||"");
varval=decodeURIComponent(this.split('=')[1]||"");
if(!key)return;
if($numbers){
if(/^[+-]?[0-9]+\.[0-9]*$/.test(val))
val=parseFloat(val);
elseif(/^[+-]?[0-9]+$/.test(val))
val=parseInt(val,10);
}
val=(!val&&val!==0)?true:val;
if(val!==false&&val!==true&&typeofval!='number')
val=val;
self.SET(key,val);
});
});
}
returnself;
};
queryObject.prototype={
queryObject:true,
has:function(key,type){
varvalue=this.get(key);
returnis(value,type);
},
GET:function(key){
if(!is(key))returnthis.keys;
varparsed=parse(key),base=parsed[0],tokens=parsed[1];
vartarget=this.keys[base];
while(target!=null&&tokens.length!=0){
target=target[tokens.shift()];
}
returntypeoftarget=='number'?target:target||"";
},
get:function(key){
vartarget=this.GET(key);
if(is(target,Object))
returnjQuery.extend(true,{},target);
elseif(is(target,Array))
returntarget.slice(0);
returntarget;
},
SET:function(key,val){
varvalue=!is(val)?null:val;
varparsed=parse(key),base=parsed[0],tokens=parsed[1];
vartarget=this.keys[base];
this.keys[base]=set(target,tokens.slice(0),value);
returnthis;
},
set:function(key,val){
returnthis.copy().SET(key,val);
},
REMOVE:function(key){
returnthis.SET(key,null).COMPACT();
},
remove:function(key){
returnthis.copy().REMOVE(key);
},
EMPTY:function(){
varself=this;
jQuery.each(self.keys,function(key,value){
deleteself.keys[key];
});
returnself;
},
load:function(url){
varhash=url.replace(/^.*?[#](.+?)(?:\?.+)?$/,"$1");
varsearch=url.replace(/^.*?[?](.+?)(?:#.+)?$/,"$1");
returnnewqueryObject(url.length==search.length?'':search,url.length==hash.length?'':hash);
},
empty:function(){
returnthis.copy().EMPTY();
},
copy:function(){
returnnewqueryObject(this);
},
COMPACT:function(){
functionbuild(orig){
varobj=typeoforig=="object"?is(orig,Array)?[]:{}:orig;
if(typeoforig=='object'){
functionadd(o,key,value){
if(is(o,Array))
o.push(value);
else
o[key]=value;
}
jQuery.each(orig,function(key,value){
if(!is(value))returntrue;
add(obj,key,build(value));
});
}
returnobj;
}
this.keys=build(this.keys);
returnthis;
},
compact:function(){
returnthis.copy().COMPACT();
},
toString:function(){
vari=0,queryString=[],chunks=[],self=this;
varencode=function(str){
str=str+"";
if($spaces)str=str.replace(//g,"+");
returnencodeURIComponent(str);
};
varaddFields=function(arr,key,value){
if(!is(value)||value===false)return;
varo=[encode(key)];
if(value!==true){
o.push("=");
o.push(encode(value));
}
arr.push(o.join(""));
};
varbuild=function(obj,base){
varnewKey=function(key){
return!base||base==""?[key].join(""):[base,"[",key,"]"].join("");
};
jQuery.each(obj,function(key,value){
if(typeofvalue=='object')
build(value,newKey(key));
else
addFields(chunks,newKey(key),value);
});
};
build(this.keys);
if(chunks.length>0)queryString.push($hash);
queryString.push(chunks.join($separator));
returnqueryString.join("");
}
};
returnnewqueryObject(location.search,location.hash);
};
}(jQuery.query||{});

.csharpcode,.csharpcodepre
{
font-size:small;
color:black;
font-family:consolas,"CourierNew",courier,monospace;
background-color:#ffffff;
/*white-space:pre;*/
}
.csharpcodepre{margin:0em;}
.csharpcode.rem{color:#008000;}
.csharpcode.kwrd{color:#0000ff;}
.csharpcode.str{color:#006080;}
.csharpcode.op{color:#0000c0;}
.csharpcode.preproc{color:#cc6633;}
.csharpcode.asp{background-color:#ffff00;}
.csharpcode.html{color:#800000;}
.csharpcode.attr{color:#ff0000;}
.csharpcode.alt
{
background-color:#f4f4f4;
width:100%;
margin:0em;
}
.csharpcode.lnum{color:#606060;}

然后我们可以通过这么调用它





2.关于图片回调还是涉及到以前做的图片公共管理简化了操作,我们只需要很简单的向GetImg.ashx请求图片,根据type尺寸,fileName和到底调用哪个方法来获取不同的图片





3.关于这个类别分组查询,去年我做的一个网页比赛中就遇到过,以前是这两个







分别是全国省市内容加载和红色事件加载,都只需要一条查询语句就能查询结果,利用了分组查询,蛮有意思的,

大致的语句

selectid,title,isnull(histroytime,0)asmonthfrom(select

id,title,histroytime,row_number()over(partitionbyhistroytimeorderby

histroytime)totalfromredCalendar)rnwherern.total<5

其实就是row_number和分组的用法

然后在程序中判断

程序主要代码:

前台:

<%@PageLanguage="C#"MasterPageFile="~/InfoPage.master"AutoEventWireup="true"
CodeFile="MasterInfo.aspx.cs"Inherits="Master_MasterInfo"Title="大师信息"%>
<asp:ContentID="Content1"ContentPlaceHolderID="head"runat="Server">
<linkhref="../css/gs_ms.css"rel="stylesheet"type="text/css"/>
<scriptsrc="../Admin/scripts/jquery-1.7.1.min.js"type="text/javascript"></script>
<scriptsrc="../js/queryUrlParams.js"type="text/javascript"></script>
<scriptsrc="MasterInfo.js"type="text/javascript"></script>
<scripttype="text/javascript">
//获得大师id信息
varid=$.query.get("MasterId");
</script>
</asp:Content>
<asp:ContentID="Content2"ContentPlaceHolderID="ContentPlaceHolder1"runat="Server">
<divclass="ms">
<divclass="ms_top">
<divclass="m_load">
<span><ahref="../Default.aspx">首页</a>><ahref="MasterList.aspx">大师风采</a>>大师</span></div>
<divclass="mst_c">
<ulclass="mst_ul">
<li><ahref="#"id="Master_Intro">
<pclass="hide">
大师简介</p>
</a></li>
<li><ahref="#"id="Master_Award">
<pclass="hide">
获奖情况</p>
</a></li>
<li><ahref="#"id="Master_Work">
<pclass="hide">
大师作品</p>
</a></li>
</ul>
<divclass="mst_img">
<imgsrc="../images/master_img.png"id="imgMaster"/></div>
<divclass="mst_xx">
<tablewidth="252"height="141"id="tbMasterInfo">
</table>
</div>
</div>
</div>
<divclass="gs_nr"id="MasterContent">
</div>
</div>
</asp:Content>


.csharpcode,.csharpcodepre
{
font-size:small;
color:black;
font-family:consolas,"CourierNew",courier,monospace;
background-color:#ffffff;
/*white-space:pre;*/
}
.csharpcodepre{margin:0em;}
.csharpcode.rem{color:#008000;}
.csharpcode.kwrd{color:#0000ff;}
.csharpcode.str{color:#006080;}
.csharpcode.op{color:#0000c0;}
.csharpcode.preproc{color:#cc6633;}
.csharpcode.asp{background-color:#ffff00;}
.csharpcode.html{color:#800000;}
.csharpcode.attr{color:#ff0000;}
.csharpcode.alt
{
background-color:#f4f4f4;
width:100%;
margin:0em;
}
.csharpcode.lnum{color:#606060;}

处理加载的ajax的js文件:


$(function(){

GetMasterInfo();

GetMasterIntro();

//绑定获取大师简介事件

$("#Master_Intro").click(function(){

GetMasterIntro();

});

$("#Master_Award").click(function(){

GetMasterReward();

});

$("#Master_Work").click(function(){

GetMasterWork();

});

});

//获取大师基本信息

functionGetMasterInfo(){

$.ajax({

url:"Data/MasterInfo.ashx?method=GetMasterInfo&MasterId="+id,

type:"post",

success:function(text){

varjsonData=$.parseJSON(text);

if(jsonData.Status){

varitem='<tr><tdwidth="51">姓名:</td>';

item+='<tdwidth="92">'+jsonData.Data[0].Name+'</td>';

item+='<tdwidth="47">性别:</td>';

item+='<tdwidth="42">'+jsonData.Data[0].Sex+'</td>';

item+='</tr>';

item+='<tr><td>出生:</td>';

item+='<td>'+jsonData.Data[0].Birthday+'</td>';

item+='</tr>';

item+='<tr><tdcolspan="4">艺术家分类:';

item+=jsonData.Data[0].TypeName;

item+='</td></tr>';


$("#tbMasterInfo").empty();

$("#tbMasterInfo").append(item);

varsrc="../Admin/FileManage/GetImg.ashx?method=GetMasterPic&type=medium&fileName="+jsonData.Data[0].PicturePath;

$("#imgMaster").attr("src",src);

}

}

});


}

//获取大师简介信息

functionGetMasterIntro(){

$.ajax({

url:"Data/MasterInfo.ashx?method=GetMasterIntro&MasterId="+id,

type:"post",

success:function(text){

varjsonData=$.parseJSON(text);

if(jsonData.Status){

varitem='<h4>大师简介</h4>';

item+='<p>'+jsonData.Data[0].Introduction+'</p>';

$("#MasterContent").empty();

$("#MasterContent").append(item);

}

}

});

}

//获取大师荣誉信息

functionGetMasterReward(){

$.ajax({

url:"Data/MasterInfo.ashx?method=GetMasterReward&MasterId="+id,

type:"post",

success:function(text){

varjsonData=$.parseJSON(text);

if(jsonData.Status){

varitem='<h4>大师荣誉</h4>';

item+='<ulclass="gs_reward">';

item+='<li>'+jsonData.Data[0].Reward+'</li></ul>';

item+='<h4>获奖情况</h4><ulclass="gs_cup">';

$.each(jsonData.Data[0].CertPicList,function(key,value){

varimg="../Admin/FileManage/GetImg.ashx?method=GetMasterCert&type=medium&fileName="+value.CertPic;

item+='<li><spanclass="c_pic_a">';

item+='<imgsrc='+img+'alt='+value.CertName+'title='+value.CertName+'/></span><spanclass="a_title">'+value.CertName+'</span>';

item+='</li>';

});

item+='</ul>';

$("#MasterContent").empty();

$("#MasterContent").append(item);

}

}

});

}

//获取大师产品信息

functionGetMasterWork(){

$.ajax({

url:"Data/MasterInfo.ashx?method=GetMasterWork&MasterId="+id,

type:"post",

success:function(text){

varjsonData=$.parseJSON(text);


if(jsonData.Status){

varitem='';

$.each(jsonData.Data,function(key,value){

item+='<h4>'+value.TypeName+'</h4>';

item+='<ulclass="gs_pic">';

$.each(value.Product,function(PKey,PValue){

varimg="../Admin/FileManage/GetImg.ashx?method=GetMainProductPic&type=medium&fileName="+PValue.Picturepath;

item+='<li>';

item+='<ahref="../Product/Product.aspx?ProductId='+PValue.ProductId+'"class="c_pic_a"><imgsrc="'+img+'"alt="'+PValue.Name+'"title="'+PValue.SimpleName+'"/></a>';

item+='<ahref="../Product/Product.aspx?ProductId='+PValue.ProductId+'"class="a_title">'+PValue.SimpleName+'<br/><spanclass="rad2">¥'+PValue.Lsprice+'</span></a>';

item+='</li>';

})

item+='</ul>';

item+='<divstyle="text-align:right"><ahref="../Product/Master_MoreProduct.aspx?MasterId='+id+'&&TypeId='+value.TypeId+'">more>></a></div>';


})

$("#MasterContent").empty();

$("#MasterContent").append(item);

}

}

});

}


类别分组的DAL方法:

///<summary>
///通过大师id查找大师的产品(每种分别显示前8个)
///</summary>
///<paramname="MasterId">大师id</param>
///<returns></returns>
publicDataTableListAllByMasterIdToDatable(stringMasterId)
{
returnSqlHelper.ExecuteDataTable("select*from(select*,row_number()over(partitionbyTypeIdorderbyTypeId)totalfromVProductCraftTypewhereMasterid=@MasteridandBelongstype='0')rnwherern.total<=8",(DbParameter)newSqlParameter("Masterid",MasterId));
}

数据库的查询效果:



BLL的主要业务逻辑处理:
下面第一个的业务逻辑是难点:
///<summary>
///根据大师id查找大师的产品信息(每种分别显示前8个)
///</summary>
///<paramname="MasterId">大师Id</param>
///<returns></returns>
publicstringGetMasterWorkForJson(stringMasterId)
{
//查询状态
boolStatus=false;
//获取大师的产品信息(每种显示前8个)
DataTabledtListProduct=newVProductCraftTypeDAL().ListAllByMasterIdToDatable(MasterId);
//转化为json格式
StringBuilderjson=newStringBuilder();
StringWritersw=newStringWriter(json);
using(JsonWriterjsonWriter=newJsonTextWriter(sw))
{
jsonWriter.Formatting=Formatting.Indented;
//判断数据读取状态
if(dtListProduct.Rows.Count>0)
{
Status=true;
}
jsonWriter.WriteStartObject();
jsonWriter.WritePropertyName("Status");
jsonWriter.WriteValue(Status);
jsonWriter.WritePropertyName("Data");
jsonWriter.WriteStartArray();
//先输出第一个元素的类别信息
jsonWriter.WriteStartObject();
jsonWriter.WritePropertyName("TypeId");
jsonWriter.WriteValue(dtListProduct.Rows[0]["TypeId"].ToString());
jsonWriter.WritePropertyName("TypeName");
jsonWriter.WriteValue(dtListProduct.Rows[0]["TypeName"].ToString());
//第一个元素的开始
jsonWriter.WritePropertyName("Product");
jsonWriter.WriteStartArray();
//按照类别分组
//产品计数(一个分组下的产品,从1开始算起)
for(intnum=0,numProduct=1;num<dtListProduct.Rows.Count;num++,numProduct++)
{
//获取该类别下的分组总个数
intTotal=Convert.ToInt32(dtListProduct.Rows[num]["total"]);
//如果该类别下还存在未输出的产品
if(numProduct<=Total)
{
jsonWriter.WriteStartObject();
jsonWriter.WritePropertyName("ProductId");
jsonWriter.WriteValue(dtListProduct.Rows[num]["Id"].ToString());
jsonWriter.WritePropertyName("Name");
jsonWriter.WriteValue(dtListProduct.Rows[num]["Name"].ToString());
jsonWriter.WritePropertyName("SimpleName");
jsonWriter.WriteValue(dtListProduct.Rows[num]["SimpleName"].ToString());
jsonWriter.WritePropertyName("Lsprice");
jsonWriter.WriteValue(dtListProduct.Rows[num]["Lsprice"].ToString());
jsonWriter.WritePropertyName("Picturepath");
jsonWriter.WriteValue(dtListProduct.Rows[num]["Picturepath"].ToString());
jsonWriter.WriteEndObject();
}
else{
//将该类别的产品计数重置为1
numProduct=1;
//这里给上一个类别的产品结束标记
jsonWriter.WriteEndArray();
jsonWriter.WriteEndObject();
jsonWriter.WriteStartObject();
jsonWriter.WritePropertyName("TypeId");
jsonWriter.WriteValue(dtListProduct.Rows[num]["TypeId"].ToString());
jsonWriter.WritePropertyName("TypeName");
jsonWriter.WriteValue(dtListProduct.Rows[num]["TypeName"].ToString());
//如果还存在产品
if(num<dtListProduct.Rows.Count)
{
//下一个元素的开始
jsonWriter.WritePropertyName("Product");
jsonWriter.WriteStartArray();
}
}
}
jsonWriter.WriteEndArray();
jsonWriter.WriteEndObject();
}
returnjson.ToString();
}

生成的json数据:

这里推荐大家一个工具,就是这个W3Cfuns前端工具,蛮好用的





.csharpcode,.csharpcodepre
{
font-size:small;
color:black;
font-family:consolas,"CourierNew",courier,monospace;
background-color:#ffffff;
/*white-space:pre;*/
}
.csharpcodepre{margin:0em;}
.csharpcode.rem{color:#008000;}
.csharpcode.kwrd{color:#0000ff;}
.csharpcode.str{color:#006080;}
.csharpcode.op{color:#0000c0;}
.csharpcode.preproc{color:#cc6633;}
.csharpcode.asp{background-color:#ffff00;}
.csharpcode.html{color:#800000;}
.csharpcode.attr{color:#ff0000;}
.csharpcode.alt
{
background-color:#f4f4f4;
width:100%;
margin:0em;
}
.csharpcode.lnum{color:#606060;}

///<summary>
///获取大师简介信息
///</summary>
///<paramname="id"></param>
///<returns></returns>
publicstringGetMasterIntroForJson(stringid)
{
//加载状态
boolStatus=false;
intMasterId=Convert.ToInt32(id);
//获取大师基本信息
masterInfo=newmasterDAL().Get(MasterId);
//转化为json格式
StringBuilderjson=newStringBuilder();
StringWritersw=newStringWriter(json);
using(JsonWriterjsonWriter=newJsonTextWriter(sw))
{
jsonWriter.Formatting=Formatting.Indented;
//判断数据读取状态
if(Info.Id.HasValue)
{
Status=true;
}
jsonWriter.WriteStartObject();
jsonWriter.WritePropertyName("Status");
jsonWriter.WriteValue(Status);
jsonWriter.WritePropertyName("Data");
jsonWriter.WriteStartArray();
jsonWriter.WriteStartObject();
jsonWriter.WritePropertyName("Introduction");
jsonWriter.WriteValue(Info.Introduction);
jsonWriter.WriteEndObject();
jsonWriter.WriteEndArray();
jsonWriter.WriteEndObject();
}
returnjson.ToString();
}
///<summary>
///获取大师获奖信息
///</summary>
///<paramname="id"></param>
///<returns></returns>
publicstringGetMasterRewardForJson(stringid)
{
//加载状态
boolStatus=false;
//获取大师荣誉证书
IEnumerable<master_cert>masterCertList=newmaster_certDAL().ListAllById(id);
intMasterId=Convert.ToInt32(id);
//获取大师基本信息
masterInfo=newmasterDAL().Get(MasterId);
//转化为json格式
StringBuilderjson=newStringBuilder();
StringWritersw=newStringWriter(json);
using(JsonWriterjsonWriter=newJsonTextWriter(sw))
{
jsonWriter.Formatting=Formatting.Indented;
//判断数据读取状态
if(Info.Id.HasValue)
{
Status=true;
}
jsonWriter.WriteStartObject();
jsonWriter.WritePropertyName("Status");
jsonWriter.WriteValue(Status);
jsonWriter.WritePropertyName("Data");
jsonWriter.WriteStartArray();
jsonWriter.WriteStartObject();
jsonWriter.WritePropertyName("Reward");
jsonWriter.WriteValue(Info.Reward);
jsonWriter.WritePropertyName("CertPicList");
jsonWriter.WriteStartArray();
foreach(master_certcertinmasterCertList)
{
jsonWriter.WriteStartObject();
jsonWriter.WritePropertyName("CertName");
jsonWriter.WriteValue(cert.Name);
jsonWriter.WritePropertyName("CertPic");
jsonWriter.WriteValue(cert.Picpath);
jsonWriter.WriteEndObject();
}
jsonWriter.WriteEndArray();
jsonWriter.WriteEndObject();
jsonWriter.WriteEndObject();
}
returnjson.ToString();
}
///<summary>
///获取大师基本信息
///</summary>
///<paramname="id">大师id</param>
///<returns></returns>
publicstringGetMasterInfoForJson(stringid)
{
//加载状态
boolStatus=false;
//获取大师类别信息
IEnumerable<VMasterType>masterTypeList=newVMasterTypeDAL().ListAllById(id);
//拼接大师类别信息
StringBuildersbTypeName=newStringBuilder();
foreach(varmasterTypeinmasterTypeList)
{
sbTypeName.Append(masterType.TypeName);
if(masterType!=masterTypeList.Last())
{
sbTypeName.Append(",");
}
}
intMasterId=Convert.ToInt32(id);
//获取大师基本信息
masterInfo=newmasterDAL().Get(MasterId);
//转化为json格式
StringBuilderjson=newStringBuilder();
StringWritersw=newStringWriter(json);
using(JsonWriterjsonWriter=newJsonTextWriter(sw))
{
jsonWriter.Formatting=Formatting.Indented;
//判断数据读取状态
if(Info.Id.HasValue)
{
Status=true;
}
jsonWriter.WriteStartObject();
jsonWriter.WritePropertyName("Status");
jsonWriter.WriteValue(Status);
jsonWriter.WritePropertyName("Data");
jsonWriter.WriteStartArray();
jsonWriter.WriteStartObject();
jsonWriter.WritePropertyName("Name");
jsonWriter.WriteValue(Info.Name);
jsonWriter.WritePropertyName("Sex");
jsonWriter.WriteValue(Info.Sex=="1"?"男":"女");
jsonWriter.WritePropertyName("Birthday");
jsonWriter.WriteValue(Info.BirthDay.Value.ToShortDateString());
jsonWriter.WritePropertyName("PicturePath");
jsonWriter.WriteValue(Info.Picturepath);
jsonWriter.WritePropertyName("TypeName");
jsonWriter.WriteValue(sbTypeName.ToString());
jsonWriter.WriteEndObject();
jsonWriter.WriteEndArray();
jsonWriter.WriteEndObject();
}
returnjson.ToString();
}

.csharpcode,.csharpcodepre
{
font-size:small;
color:black;
font-family:consolas,"CourierNew",courier,monospace;
background-color:#ffffff;
/*white-space:pre;*/
}
.csharpcodepre{margin:0em;}
.csharpcode.rem{color:#008000;}
.csharpcode.kwrd{color:#0000ff;}
.csharpcode.str{color:#006080;}
.csharpcode.op{color:#0000c0;}
.csharpcode.preproc{color:#cc6633;}
.csharpcode.asp{background-color:#ffff00;}
.csharpcode.html{color:#800000;}
.csharpcode.attr{color:#ff0000;}
.csharpcode.alt
{
background-color:#f4f4f4;
width:100%;
margin:0em;
}
.csharpcode.lnum{color:#606060;}

这样这次的任务就完成了,总体感觉蛮不错的,效果很好,就是那个json数据拼接拼了好久,纠结了好久.
接下来,尽快把这个项目完整的做完,静态页面管理,大师空间,企业空间,第三方支付平台,等等,然后步入asp.netmvc学习.....哈哈!

.csharpcode,.csharpcodepre
{
font-size:small;
color:black;
font-family:consolas,"CourierNew",courier,monospace;
background-color:#ffffff;
/*white-space:pre;*/
}
.csharpcodepre{margin:0em;}
.csharpcode.rem{color:#008000;}
.csharpcode.kwrd{color:#0000ff;}
.csharpcode.str{color:#006080;}
.csharpcode.op{color:#0000c0;}
.csharpcode.preproc{color:#cc6633;}
.csharpcode.asp{background-color:#ffff00;}
.csharpcode.html{color:#800000;}
.csharpcode.attr{color:#ff0000;}
.csharpcode.alt
{
background-color:#f4f4f4;
width:100%;
margin:0em;
}
.csharpcode.lnum{color:#606060;}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: