Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: MVC4
Hi,
 
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 5:10am
Rate this: bad
good
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>
  Permalink  
v2
Comments
Ahamed Azeem at 7-Feb-13 14:06pm
   
Bro, it will not be same always.. I want it to take dynamically
Sheikh Muhammad Haris at 7-Feb-13 14:12pm
   
You didn't mention it in your question. Then why don't you use viewbag?
Ahamed Azeem at 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 at 7-Feb-13 14:17pm
   
and the link to this page is in another view
Ahamed Azeem at 7-Feb-13 14:28pm
   
I solved this myself @ViewContext.RouteData.Values["id"]
Sheikh Muhammad Haris at 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
good
Please Sign up or sign in to vote.

Solution 3

@ViewContext.RouteData.Values["id"]
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 554
1 Gihan Liyanage 338
2 RyanDev 248
3 Sergey Alexandrovich Kryukov 243
4 ChauhanAjay 220
0 Sergey Alexandrovich Kryukov 9,011
1 OriginalGriff 7,941
2 CPallini 2,603
3 Richard MacCutchan 2,121
4 Abhinav S 1,928


Advertise | Privacy | Mobile
Web02 | 2.8.140827.1 | Last Updated 7 Feb 2013
Copyright © CodeProject, 1999-2014
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