By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,795 Members | 1,666 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,795 IT Pros & Developers. It's quick & easy.

How get Request.Querystring from IFrame page

P: n/a
I have an ASPX page that is used for content. I have a master page which
sticks the page in an IFrame.

Question: From the content/ASPX page, I can't seem to reference
request.querystring. Any way around this? I need to read it.

Thanks!
Nov 18 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
VB Programmer wrote:
I have an ASPX page that is used for content. I have a master page
which sticks the page in an IFrame.

Question: From the content/ASPX page, I can't seem to reference
request.querystring. Any way around this? I need to read it.


The "outer" page should be constructed in such a way that it appends the
query string to the IFRAME's target URL.

Cheers,

--
Joerg Jooss
www.joergjooss.de
ne**@joergjooss.de
Nov 18 '05 #2

P: n/a
How do I do that?

"Joerg Jooss" <jo*********@gmx.net> wrote in message
news:uo****************@TK2MSFTNGP14.phx.gbl...
VB Programmer wrote:
I have an ASPX page that is used for content. I have a master page
which sticks the page in an IFrame.

Question: From the content/ASPX page, I can't seem to reference
request.querystring. Any way around this? I need to read it.


The "outer" page should be constructed in such a way that it appends the
query string to the IFRAME's target URL.

Cheers,

--
Joerg Jooss
www.joergjooss.de
ne**@joergjooss.de

Nov 18 '05 #3

P: n/a
VB Programmer wrote:
How do I do that?


Make the IFRAME a HtmlControl and append Request.QueryString to the IFRAME's
"src" attribute in the outer page's code behind class.

Cheers,
--
Joerg Jooss
www.joergjooss.de
ne**@joergjooss.de

Nov 18 '05 #4

P: n/a
Any examples of how to do this? Thanks!

"Joerg Jooss" <jo*********@gmx.net> wrote in message
news:uQ**************@TK2MSFTNGP14.phx.gbl...
VB Programmer wrote:
How do I do that?


Make the IFRAME a HtmlControl and append Request.QueryString to the
IFRAME's "src" attribute in the outer page's code behind class.

Cheers,
--
Joerg Jooss
www.joergjooss.de
ne**@joergjooss.de

Nov 18 '05 #5

P: n/a
VB Programmer wrote:
Any examples of how to do this? Thanks!


Here's the code-behind class for a Web Form with an IFRAME HTML control with
an ID "iframe", that shows how to append the Web Form's query string to the
IFRAME's src attribute:

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace TestWebApp {
/// <summary>
/// Zusammenfassung für IFrameDemo.
/// </summary>
public class IFrameDemo : System.Web.UI.Page {
protected System.Web.UI.HtmlControls.HtmlGenericControl iframe;

private void Page_Load(object sender, System.EventArgs e) {
this.iframe.Attributes["src"] += UrlEncodedQueryString;
}

private string UrlEncodedQueryString {
get {
ICollection keys = Request.QueryString.Keys;
StringBuilder builder = new StringBuilder("?", 2048);
foreach (string key in keys) {
builder.AppendFormat("{0}={1}&", key,
HttpUtility.UrlEncode(
Request.QueryString[key],
Encoding.UTF8));
}
// This will either cut the ? for empty query strings
// or the surplus & for non-empty ones. Just makes the
// query string look nice all the time ;-)
builder.Length -= 1;

return builder.ToString();
}
}

// Cut generated code...
}

As you can see, it's trivial. The interesting part was providing a means to
URL encode the query string again (there seems to be no method in the FCL
that works on an existing query string without escaping & or ? as well).

Note that this sample assumes the query string's URL encoding is UTF-8
based.

Cheers,

--
Joerg Jooss
www.joergjooss.de
ne**@joergjooss.de
Nov 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.