Jack
Jack

Reputation: 53

Getting a remote file and fill a dropdown list

Ok, I have a silly question to ask. I have to get this page with a jquery function and fill a dropdown list with data in an asp.net form. Any ideas or examples?

Upvotes: 0

Views: 193

Answers (2)

Tom Pickles
Tom Pickles

Reputation: 900

I would do it indirectly using a page method in your codebehind, not directly using jquery due to being blocked by x-site scripting protection.

I'd write a simple class which uses a webclient in .net to pull the page contents back and parse the response into a List<string> and return to your control somehow. Depending on if you're using jquery/jscript or an updatepanel in ASP.net, you can call the class method from within your code behind method to prevent a full postback and bind/populate your dropdown list with the data.

Example code is in the response marked answered in this previous post.

Upvotes: 1

H&#252;seyin Z.
H&#252;seyin Z.

Reputation: 836

Cross site scripting is blocked by most browsers. You could use jsonp dataype in your ajax request but the target link don't provide this data type. So, -probably- not possible with javascript.

Upvotes: 0

Related Questions