Click here to Skip to main content
12,700,871 members (29,388 online)
Rate this:
Please Sign up or sign in to vote.
See more: MVC4

I have a view, inside view i am calling an aspx page to load report viewer. I wanted to pass the parameter of the url to the aspx page which is inside the iframe.

The browser url is localhost/Contract/ContractReport/12233

I want 12233 to be passed to the iframe source as ../../ContractReport.aspx?12233

Please give me suggestions
Posted 7-Feb-13 6:10am
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Simple call your page like this
<iframe src="/ContractReport.aspx?12233"></iframe>

------------- Updated Answer below

Set your URL in controller like this
public ActionResult Index()
     ViewBag.myURL = "/abc.aspx?" + querystring; // set your dynamic URL here
     return View();

Then in your View,
<iframe id="iframe" src="@Url.Content(ViewBag.myURL)" style="width: 700; height: 700px;"></iframe>
Ahamed Azeem 7-Feb-13 14:06pm
Bro, it will not be same always.. I want it to take dynamically
Sheikh Muhammad Haris 7-Feb-13 14:12pm
You didn't mention it in your question. Then why don't you use viewbag?
Ahamed Azeem 7-Feb-13 14:17pm
Yes I forgot to put for ex.

This is get so how can i use viewbag to pass from the controller
Ahamed Azeem 7-Feb-13 14:17pm
and the link to this page is in another view
Ahamed Azeem 7-Feb-13 14:28pm
I solved this myself @ViewContext.RouteData.Values["id"]
Sheikh Muhammad Haris 7-Feb-13 17:19pm
Glad you solved it yourself.

Just for example, I have updated my Answer, how could you use this with ViewBag.
Rate this: bad
Please Sign up or sign in to vote.

Solution 3


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170118.1 | Last Updated 7 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100