简体   繁体   English

读取客户端页面数据asp.net和C#

[英]Read client page data asp.net and c#

Hi anybody know how to select and read client page data using c# and asp.net? 嗨,有人知道如何使用c#和asp.net选择和读取客户端页面数据吗?

Here I'm tring to load a page using iframe in my application. 在这里,我正在尝试在应用程序中使用iframe加载页面。 Now i want to select some specific text and want to store it in my local database. 现在,我想选择一些特定的文本并将其存储在本地数据库中。

Is it possible? 可能吗?

I'm going through snagit tool but it is capturing the selected area but unable to read the content and store it. 我正在使用snagit工具,但它正在捕获所选区域,但无法读取内容并将其存储。

Thanks in advance, Nagu 在此先感谢Nagu

If the objective is to read the data from a url 如果目标是从网址读取数据

You can do it from the server side itself. 您可以从服务器端本身进行操作。 You can do the same using the WebClient class. 您可以使用WebClient类执行相同的操作。

WebClient client = new WebClient ();
client.Headers.Add ("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2)");
Stream data = client.OpenRead ("http://yoururl.com");
StreamReader reader = new StreamReader (data);
string s = reader.ReadToEnd ();

If the objective is to fetch some data from the client side and save it in the server 如果目标是从客户端获取一些数据并将其保存在服务器中

Then you might need to write some javascript at client side to fetch the html, and send it to the server over an ajax/normal postback and then store it from there 然后,您可能需要在客户端编写一些JavaScript来获取html,然后通过ajax /普通回发将其发送到服务器,然后从那里进行存储

You might need some javascript to acheive this. 您可能需要一些JavaScript才能达到目的。 If you want to fetch the IFrame content, do something like 如果您想获取IFrame内容,请执行以下操作

var range = myiFrameName.document.selection.createRange(); 
var str = range.text;
//Code to postback

Also, have a look at this http://www.webreference.com/js/column12/final.html 另外,请查看此http://www.webreference.com/js/column12/final.html

Trust this helps 相信这会有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM