views:

410

answers:

2

Hi anybody know how to select and read client page data using c# and asp.net?

Here I'm tring to load a page using iframe in my application. 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.

Thanks in advance, Nagu

+2  A: 

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 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

You might need some javascript to acheive this. If you want to fetch the IFrame content, do something like

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

Trust this helps

amazedsaint
A: 

Thank you it has provided a path for me to start.

Nagu