Hanady
Hanady

Reputation: 789

How do I pass parameters throught ifram in asp.net?

I am working on a web application in ASP.Net and I am implementing a Network Graph Library. The Network Graph is located on a page called Test.aspx. I am calling Test.aspx through iframe:

 DetailsBody.Text = DetailsBody.Text + "<td><iframe scrolling=\"no\" 
 id=\"graphframe\" src=\"Test.aspx\" width=\"100%\" 
 height=\"275px\"></iframe></td>";

I need to pass a parameter from the page where the iframe is located to the Test.aspx page.

Thanks in advance

Upvotes: 0

Views: 9397

Answers (3)

jr pineda
jr pineda

Reputation: 186

You can use any of the following approach:

  1. Session - provided that the pages are on a single web application.
  2. Query strings - dynamically append query string when defining the iframe src attribute.

Upvotes: 1

Dinesh Guptha
Dinesh Guptha

Reputation: 97

If you want to Pass the parameters through the Code behind,

 HtmlControl frame1 = (HtmlControl)this.FindControl("I_Frame_Name");
        frame1.Attributes["src"] = "Test.aspx";
        frame1.Attributes["scrolling"] = "no";
        frame1.Attributes["id"] = "graphframe";
        frame1.Attributes["width"] = "100%";
        frame1.Attributes["height"] = "275px";

Upvotes: 0

4b0
4b0

Reputation: 22323

You may pass the param like this.

<iframe src="Test.aspx?YourParam=<%=somevariable%>" scrolling=\"no\" width="100" height="275px" frameborder="0"></iframe>

and for multipal param:

<iframe src="Test.aspx?Param1=<%=somevariable%>&Param2=<%=vartwo%>&Param3=<%=varthree%>" scrolling=\"no\" width="100" height="275px" frameborder="0"></iframe>

Upvotes: 2

Related Questions