问题描述
<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="Default.aspx.cs"Inherits="_Default"%><!DOCTYPEhtml><htmlxmlns="http://www.w3.org/1999/xhtml"><headrunat="server"><metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/><title></title><scriptsrc="JS/easyUI/jquery-1.7.2.min.js"type="text/javascript"></script><scriptsrc="JS/easyUI/jquery.easyui.min.js"type="text/javascript"></script><scriptsrc="JS/easyUI/locale/easyui-lang-zh_CN.js"type="text/javascript"></script><linkhref="JS/easyUI/themes/gray/easyui.css"rel="stylesheet"type="text/css"/><linkhref="JS/easyUI/themes/icon.css"rel="stylesheet"type="text/css"/><scriptsrc="JS/wikmenu.js"type="text/javascript"></script><scriptsrc="JS/wikmain.js"type="text/javascript"></script><styletype="text/css">#TextArea1{height:121px;width:482px;}</style><scripttype="text/javascript">$(function(){$("#btn_jx").click(function(){//$.post("Default.aspx",//{value:$("#TextArea1").val()},//function(res){InitGrid();//})});});//初始化表格functionInitGrid(){//varjsons=$.parseJSON(res);$('#tab_list').datagrid({title:'数据列表',//表格标题//data:jsons['rows'],//请求数据的页面//data:jsons['rows'],url:'Default.aspx',queryParams:{value:$("#TextArea1").val()},width:'1200',//宽度height:'500',//高度nowrap:false,//是否换行,True就会把数据显示在一行里striped:true,//True奇偶行使用不同背景色collapsible:false,//可折叠sortOrder:'desc',//排序类型columns:[[{title:'政策列表',field:'zhc',width:80},{title:'自动出票',field:'zdcp',width:80},{title:'运价',field:'price',width:80},{title:'代理费',field:'dl',width:80},{title:'奖励',field:'jl',width:80},{title:'单张利润',field:'dz',width:80},{title:'开票费',field:'kpf',width:80},{title:'单张结算价',field:'dzjs',width:80},{title:'使用条件',field:'sytj',width:200},{title:'使用条件1',field:'sytj1',width:200},{title:'出票时间',field:'cpsj',width:80}]],//pagination:true,//是否开启分页//pageNumber:1,//默认索引页//pageSize:10,//默认一页数据条数rownumbers:true,//行号//onLoadError:function(){//$.messager.alert('提示','数据为空!','warning')//}});}</script></head><body><formaction="Default.aspx"method="get"><tableid="tab_list"></table><textareaid="TextArea1"name="S1"height="150px"width="500px"></textarea><inputtype="button"id="btn_jx"value="解析"//><br/><labelid="lbl_ji"runat="server"></label></form></body></html>
这是Default.aspx页面
解决方案
解决方案二:
usingSystem;usingSystem.Collections;usingSystem.Collections.Generic;usingSystem.Data;usingSystem.Linq;usingSystem.Text.RegularExpressions;usingSystem.Web;usingSystem.Web.Script.Serialization;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;publicpartialclass_Default:System.Web.UI.Page{protectedvoidPage_Load(objectsender,EventArgse){if(!string.IsNullOrEmpty(Request.Form["value"])){stringstr=Request.Form["value"];str=str.Replace("n","r");stringbackString=string.Empty;stringpath=Request.MapPath("有数据.html");System.Net.WebClientwc=newSystem.Net.WebClient();wc.Encoding=System.Text.Encoding.GetEncoding("gb2312");stringhtml=wc.DownloadString(path);//StringResultString=html;stringresult="";DataTabledt1=SqlHelper.GetTable("select*fromgetHtml");stringregCert=dt1.Rows[1]["Regex"].ToString();MatchCollectionmc2=Regex.Matches(html,regCert);//RegexregCert=newRegex("<table[^>]*>[\s\S]*?</table>",RegexOptions.IgnoreCase);//Matchmth=regCert.Match(ResultString);//if(mc2[0].Success)//{//result=mc2[0].Groups[0].Value;//获取第一个table//}if(mc2.Count>0){result=mc2[0].Groups[0].ToString();}else{return;//没有table}stringsr=result;DataTabledt2=SqlHelper.GetTable("select*fromgetHtml");stringreg=dt2.Rows[2]["Regex"].ToString();MatchCollectionmc3=Regex.Matches(sr,reg);//Regexre=newRegex("<tr[^>]*>[\s\S]*?</tr>",RegexOptions.IgnoreCase);//Matchmc=re.Match(sr);//if(mc.NextMatch().Value.Trim()=="")//没有数据//{//return;//}if(mc3[0].NextMatch().Value.Trim()==""){return;//无数据}//有数据放入datagridDataTabledt=SqlHelper.GetTable("select*fromgetHtml");stringregex=dt.Rows[0]["Regex"].ToString();MatchCollectionmc1=Regex.Matches(html,regex);if(mc1.Count>0){JavaScriptSerializerjs=newJavaScriptSerializer();List<result02>list=newList<result02>();for(inti=0;i<mc1.Count;i++){result02m=newresult02();m.zhc=mc1[i].Groups[1].ToString();m.zdcp=mc1[i].Groups[2].ToString();m.price=mc1[i].Groups[3].ToString();m.dl=mc1[i].Groups[4].ToString();m.jl=mc1[i].Groups[5].ToString();m.dz=mc1[i].Groups[6].ToString();m.kpf=mc1[i].Groups[7].ToString();m.dzjs=mc1[i].Groups[8].ToString();m.sytj=mc1[i].Groups[9].ToString();m.sytj1=mc1[i].Groups[10].ToString();m.cpsj=mc1[i].Groups[11].ToString();list.Add(m);}Hashtabletable=newHashtable();backString=js.Serialize(list);backString="{rows:["+backString+"]}";strings=js.Serialize(new{total=mc1.Count,rows=list});Response.Write(s);Response.Flush();Response.End();}else{return;//正则错误}}}}
这是Default.aspx.cs页面[b][size=14px]我用下面url绑定数据就可以现在想换成post形式的来给小弟支支招吧谢谢!!![[/size]/b]
解决方案三:
快来人啊不然要死人了!!11!!!
解决方案四:
人都哪去了啊