在MVC

时间:2017-06-08 06:28:59

标签: c# html asp.net-mvc bookmarks

我有两个观点; Index和Giftworx。在索引中我有图标,当点击每个图标时,它应该将用户引导到GiftWorx页面中的特定点。我尝试了下面的代码,但它没有用。任何帮助将不胜感激。

索引视图:

 <div class="col-md-4 w3_agileits_features_grid">
                <div class="agileits_w3layouts_features_grid">
                    <div class="col-xs-4 agileits_w3layouts_features_gridl">
                        <div class="agile_feature_grid">
                            @*<a href="@Url.Action("GiftWorx","Home", "GiftWorxUsers")"> <i class="fa fa-gift" aria-hidden="true"></i></a>
            </div>*@
                            <a href="/Home/GiftWorx/#GiftWorxUsers"> <i class="fa fa-gift" aria-hidden="true"></i></a>
                        </div>
                    </div>
                    <div class="col-xs-8 agileits_w3layouts_features_gridr">
                        <h4>Who uses GiftWorx</h4>
                        <p>See who uses GiftWorx and more.</p>
                    </div>
                    <div class="clearfix"> </div>
                </div>
            </div>

GiftWorxView

<div class="why-convertible-box" id="GiftWorxUsers">
    <div class="container" id="GiftWorxUsers">
        <h1>Who uses GiftWorx<i class="fa fa-question-circle"></i></h1>
    </div>
</div>
<div class="hoc container clear" id="GiftWorxUsers">
    <div class="row">
        <div class="col-md-2" style="padding: 2px;">
            <div style="border: lightgrey solid thin; border-radius: 2px">
                <img class="img-responsive" style="height:auto;" src="~/Content/myTemplate/Logos/1.jpg" />
            </div>
        </div>
        <div class="col-md-2" style="padding: 2px;">
            <div style="border: lightgrey solid thin; border-radius: 2px">
                <img class="img-responsive" src="~/Content/myTemplate/Logos/17.jpg" />
            </div>
        </div>
        <div class="col-md-2" style="padding: 2px;">
            <div style="border: lightgrey solid thin; border-radius: 2px">
                <img class="img-responsive" src="~/Content/myTemplate/Logos/15.jpg" />
            </div>
        </div>

1 个答案:

答案 0 :(得分:0)

这有点棘手,但应该可以正常工作。首先,我使用页面的连接部分声明变量:

@{
    var strLink = Url.Action("GiftWorxUsers", "GiftWorx") + "#GiftworxArea";
}

然后在您的索引视图上,将其放在您的href链接上:

<div class="agile_feature_grid">
     <a href='@strLink'> 
      <i class="fa fa-gift" aria-hidden="true">
      </i>
     Link text here
     </a>
</div>    

确保您在View of Giftworx中有一个区域,在此示例中有一个名称: Giftworx ,添加以下代码:

<a name="GiftworxArea"></a>
<div class="col-md-4 w3_agileits_features_grid">
   //Other stuffs here
</div>

现在,当您点击该链接时,系统会在您的页面上指定您的页面,其中包含 GiftworxArea 的部分名称。