Monday, March 12, 2012

Want to be able to pass parameters to an IFRAME

I've got 2 ASP.NET WebPages that I've written in VB.NET 2003. One of them
has several controls on it, including at the bottom of the page an IFrame.
The second ASP.NET page is supposed to have parameters passed to it in the
query string. My problem is that I cannot figure out how to
programmatically change the parameters that are passed to the second ASP.NET
page, from the first ASP.NET page.

How is this done?

Rodin aspx:

<iframe id="footer" runat=server
in code behind

footer.Attributes["src"] = "page2.aspx?p1=" + HttpUtility.UrlEncode(p1);

-- bruce (sqlwork.com)

"Rod" <rodf@.newsgroups.nospam> wrote in message
news:uJhQimJgEHA.1644@.tk2msftngp13.phx.gbl...
> I've got 2 ASP.NET WebPages that I've written in VB.NET 2003. One of them
> has several controls on it, including at the bottom of the page an IFrame.
> The second ASP.NET page is supposed to have parameters passed to it in the
> query string. My problem is that I cannot figure out how to
> programmatically change the parameters that are passed to the second
ASP.NET
> page, from the first ASP.NET page.
> How is this done?
> Rod
Hi Rod,

As for the dynamically setting querystring items passed to the inner iframe
page, I think bruce 's suggestion is qutie good. First declare the <iframe
runat="server" id="frm"> element as a HtmlGenericControl, such as
protected System.Web.UI.HtmlControls.HtmlGenericControl frm;

so t hat we can reference it in code behind and then change the "src"
atrribute as we like. In addition, if you want to make it in the aspx page
inline, you can also define a function to dynamically generate the
querysting items , for example:

<iframe id="frm" src="http://pics.10026.com/?src=innerpage.aspx?<% BuildQueryString()%>"
"BuildQueryString" can be a public helper function in the page class that
generate the querystring list.
Hope also helps.Thanks.
Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
Thank you, Bruce, that did the trick.

Rod

"bruce barker" <nospam_brubar@.safeco.com> wrote in message
news:uOeGLXKgEHA.3320@.TK2MSFTNGP11.phx.gbl...
> in aspx:
> <iframe id="footer" runat=server >
> in code behind
> footer.Attributes["src"] = "page2.aspx?p1=" +
HttpUtility.UrlEncode(p1);
>
> -- bruce (sqlwork.com)
>
> "Rod" <rodf@.newsgroups.nospam> wrote in message
> news:uJhQimJgEHA.1644@.tk2msftngp13.phx.gbl...
> > I've got 2 ASP.NET WebPages that I've written in VB.NET 2003. One of
them
> > has several controls on it, including at the bottom of the page an
IFrame.
> > The second ASP.NET page is supposed to have parameters passed to it in
the
> > query string. My problem is that I cannot figure out how to
> > programmatically change the parameters that are passed to the second
> ASP.NET
> > page, from the first ASP.NET page.
> > How is this done?
> > Rod
Hi Steven,

You are correct, Bruce's suggest works like a charm. Your suggestion for
making a making a function to dynamically build the querystring looks as
though it would add to what Bruce provided.

Rod

"Steven Cheng[MSFT]" <v-schang@.online.microsoft.com> wrote in message
news:h6EskOOgEHA.3356@.cpmsftngxa06.phx.gbl...
> Hi Rod,
> As for the dynamically setting querystring items passed to the inner
iframe
> page, I think bruce 's suggestion is qutie good. First declare the <iframe
> runat="server" id="frm"> element as a HtmlGenericControl, such as
> protected System.Web.UI.HtmlControls.HtmlGenericControl frm;
> so t hat we can reference it in code behind and then change the "src"
> atrribute as we like. In addition, if you want to make it in the aspx page
> inline, you can also define a function to dynamically generate the
> querysting items , for example:
> <iframe id="frm" src="http://pics.10026.com/?src=innerpage.aspx?<% BuildQueryString()%>">
>
> "BuildQueryString" can be a public helper function in the page class that
> generate the querystring list.
> Hope also helps.Thanks.
> Regards,
> Steven Cheng
> Microsoft Online Support
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
> Get Preview at ASP.NET whidbey
> http://msdn.microsoft.com/asp.net/whidbey/default.aspx

0 comments:

Post a Comment