Open TreeView selected node url of multiple Controller in iframe in ASP.Net MVC

Last Reply 8 days ago By dharmendr

Posted 10 days ago

i have 2 controller Action 

StartUp and Index

i am populating Treeview on DashBoard as a partial View when i stand up at EG URL 'WWW.GOOGLE.COM'

http://localhost:19607/Normal_User/Staup 

treeview populated but when i click to the tree view node its redirect to the URL 

when i stand up at 

http://localhost:19607/Normal_User/Index

its work fine like this example

https://www.aspforums.net/Threads/183110/Open-TreeView-selected-node-url-in-iframe-in-ASPNet-MVC/

Iframe in Index View

My Query is When Ever I click or where i standup i click to the tree view node  url open in index view iframe

Index View

@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_DashBoard.cshtml";
}
 
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>
    @*<link href="~/Contents/css/bootstrap.css" rel="stylesheet" type="text/css" />*@
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
</head>
<body>
    @*<div>
        @Html.Raw(ViewBag.DOM_TreeViewMenu)
    </div>*@  
    <script src="https://code.jquery.com/jquery-1.11.3.js" type="text/javascript"></script>
    @*<script src="~/Contents/js/bootstrap.js" type="text/javascript"></script>*@
    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script> 
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
    <script type="text/javascript">
    $(function () {
        $('a').on("click", function () {
            $('[id*=iframeLink]').attr("src", $(this).attr('href'));
            return false;
        });
    });
    </script>
    <div> 
        <iframe id="iframeLink" width="100%" height="700px"  ></iframe>
    </div>
</body>
</html>

StartUp View

@{
    ViewBag.Title = "Startup";
    Layout = "~/Views/Shared/_DashBoard.cshtml";
}
 
<h2>USER PANEL</h2>
<li id="menu-academico">
    @*@Html.Raw(ViewBag.DOM_TreeViewMenu)*@
    <a href="#"><i class="lnr lnr-book"></i> <span>@Html.Raw(ViewBag.DOM_TreeViewMenu)</span></a>
</li>

my query is when after login my tree view populte on dashboard as a master page and @html.raw in in _DashBoard used as a partial view 

when i click to shoes it open iframe But when i am stand on the next controller i does not onpen in the same view it redirect to the link

You are viewing reply posted by: dharmendr 8 days ago.
Posted 8 days ago

Hi onais,

Check the below example.

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
    $(function () {
        $('a').on("click", function () {
            $('[id*=iframeLink]').attr("src", $(this).attr('href'));
            $('[id*=iframeLink]').attr("style", "display: block");
            return false;
        });
    });
</script>
<div>
    <a href="https://www.aspforums.net/">ASPForums</a>
    <br />
    <a href="https://www.aspsnippets.com/">ASPSnippets</a>
    <br />
    <iframe id="iframeLink" style="display: none"></iframe>
</div>

Demo

I agree, here is the link: https://www.e-iceblue.com/Introduce/spire-office-for-net-free.html