All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
SQL中CASE的用法_[SQL,Server教程]
ASP.NET从零起步设计网站全过程(7)_[Asp.Net教程]
c#中GDI+图形图像:GDI+中的椭圆和弧使用方法
ASP.NET中常用的文件上传下载方法_[Asp.Net教程]
PHP针对配置文件操作的最常用四个ini函数_php资料_编程技术
动态网页制作技巧PHP:详细彻底学习Smarty_php资料_编程技术
DELPHI构件的概念以及制作方法
ASP.NET数据库编程快速入门之技术慨述_[Asp.Net教程]
ASP.NET技巧:dot,net,html分析类库_.net资料_编程技术
过滤ASP.NET输出HTML中的无用空格_[Asp.Net教程]
Reading number is top 10 pictures
The real super beauty2
Original author said, this is the Hengyang people
做运动的校花1
The beginning and end
So beauty, will let you spray blood2
Nine school beauty star those gossip matters
A man's favorite things14
餐桌上的鱼
这才是真正的人体艺术1
代沟,真好
Download software ranking
DreamWeaver8
Tram sex maniac 2 (H) rar bag3
linux高级编程
WebService在.NET中的实战应用教学视频 → 第3集
Proficient in JavaScript
C语言教程TXT
C#高级编程(第4版)
Boxer vs Yellow2
Unix video tutorial8
美女写真1
delv published in(发表于) 2014/1/6 9:03:12 Edit(编辑)
ASP.NET利用webclient获取页面源代码的解决方法_[Asp.Net教程]

ASP.NET利用webclient获取页面源代码的解决方法_[Asp.Net教程]

ASP.NET利用webclient获取页面源代码的解决方法_[Asp.Net教程]























页面中包括DataGrid时,利用webclient获取页面源代码的解决方


主要问题,利用webclent获取页面源代码时,当页面中含有datagrid,并且该控件使用了自带的分页功能时,正常的方法只能获取第一页面的数据,其它页面的数据取不到,以下是解决方法。




  方法一:




  主要思路是利用webclient,post数据到服务来取得数据,这里主要用了一个小工具可以分析页面的组成及运行过程,分析中发现当点击下一页时,会Post三个参数过去, 分别是:__EVENTTARGET、__EVENTARGUMENT、__VIEWSTATE。这里__VIEWSTATE参数在从打开第一页数据时取得,__EVENTTARGET为要调用控件的名称(可以通过httpwatch来获取) ,__EVENTARGUMENT是调用事件时的参数,代码如下:




string result="";
result = this.loadtop ("http://localhost/ProjectInfo.aspx?JOBNO1=2001-09110");
string vie = GetTagContent(result,"name=\"__VIEWSTATE\" value=\"","\" />");
vie=vie.Replace ("name=\"__VIEWSTATE\" value=\"","");
vie=vie.Replace ("\" />","");
WebClient a = new WebClient();
NameValueCollection na = new NameValueCollection();
na.Add("__EVENTTARGET","NewHouseGridModule1:ModuleSplitPage:lbnNextPage");
na.Add("__VIEWSTATE",vie);
byte [] ss = a.UploadValues("http://localhost/ProjectInfo.aspx?JOBNO1=2001-09110","POST",na);
Encoding encode=Encoding .GetEncoding ("utf-8");
result=encode.GetString(ss);




  方法二:




  利用axWebBrowser控件,下载第一页,然后在最下面这如下代码:









来源:博客园












































添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.