• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 531
  • Last Modified:

Asp.net Accessing SQLDataSource SELECTCommand from Iframe

Are there any ways to access parent page's Select command for SQLdatasource from iframe?
The iframe contains listboxes and it creates SQL select statement based on the selections.
I would like to pass it to parent page and show new results.

Is it possible?

Thank you
0
jtuttle99
Asked:
jtuttle99
  • 2
1 Solution
 
ullfindsmitCommented:
That is not possible in .Net

The two pages are independent of one another and have no relation when the page request is being made.

However, if you absolutely wanted to do it, you could simply call the parent page via a HTTP WebRequest and have the page return you just the SQL by using a param you decide on.
0
 
jtuttle99Author Commented:
Could you provide me sample code using HTTP WebRequest ? Is it not recommended method??? Do you think Viewstate works?

Thank you
0
 
ullfindsmitCommented:
Two different pages do not share viewstate so it wont work
HTTP Web Request is not recommemded but that should solve your problem.


You can use the code below to make a request, make sure you change the URL to your page's URL

Also on the main page you might want to add a parameterized condition that would return the SQL

Ex:

If IsPageLoad Then
 If request.querystring("RETURNSQL") <> "" Then
  Response.Clear
  Response.Write("Select 1")
  Response.End
 End If
End If
HttpWebRequest Req = (HttpWebRequest) WebRequest.Create("http://www.aspcode.net/articles/googlesitemap.ashx");
			Req.CookieContainer = CC; 

			WebResponse webResponse = Req.GetResponse();
			string sTxt = new System.IO.StreamReader(webResponse.GetResponseStream(),
				System.Text.Encoding.Default).ReadToEnd();
			webResponse.Close();

Open in new window

0
 
CodeCruiserCommented:
You can probably use the QueryStringParameters

http://www.aspnet101.com/2007/11/using-the-querystringparameter/
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now