How to use an iframe in mvc
Posted on 2012-08-26
I'm building a web page that produces very wide svg graphics. Objects on the page must be able to be dragged past the right or left view, scrolling the view left or right as the item is dragged. In addition, there is a left area and right area that border the main svg graphics area. So you have a left area, middle area and right area. The graphics are in the middle area. The graphic objects exceed the right boundary of the center area, and I need to scroll left or right, while the two border areas remain in place. I think I need an iframe here. I've never used an iframe in an mvc page and need some help figuring out exactly how to do this.
Does the target of the iframe have to be an html page, or can it be a cshtml view? Also any other good information on accessing and manipulating this iframe content will be very helpful to me - an example would be great.
I have been able now, to get the iframe to work with mvc. I basically just create an iframe with an empty source. Then in some jquery code, I set the source equal to the controller / action that delivers the view. This works.
However, my problem now is that in this iframe, as the user trys to drag an svg object off the right boundary of the iframe, I need to manually scroll the iframe - so that the dragged svg image is moving right with the scrolling iframes content. This allows the user to drag from the visible view, into an area of the view that he/she scrolls to right or left.
this is where I am on this. I'm not having luck at trying to get this type of manual scrolling to work. Is there any way to tell the iframe to scroll right when certain events take place?