close button needs to be near the list item - c#

incorrect align
https://pasteboard.co/IbSMzuh.jpg
should be like that https://pasteboard.co/IbSNyXW.jpg
here is the code:
{
<li> #requestUser.User.FullName #if (Model.IsAdmin) { #Html.ActionLink("x", "RemoveRequestUser", new { id = requestUser.Id }, new { #class = "close" ,Position.Left})} </li>
}

Related

Html.Actionlink executing if then block in view

I'm new to C#, and I'm wondering if it's possible to use an #Html.ActionLink command to execute a block of code in the same view?
So for example:
//bootstrap tab button 1
<#Html.ActionLink("Community", "", new {id="Community"}, new {#class= "nav-link active" }, new {data-toggle="tab"})
//bootstrap tab button 2
<#Html.ActionLink("Health", "", new {id="Health"}, new {#class= "nav-link" }, new {data-toggle="tab"})
<div id="Community"> //some code here </div>
<div id="Health"? //some code here </div>
Ideally there would be a default choice made on page load (community), and then when the user clicked on either the community, or health buttons(bootstrap tabs style) the corresponding code block would get run.
Not sure if this is possible with the Actionlink command, or perhaps there's a better/easier/simpler way to accomplish these tasks.
Update:
Attempted a solution below, and had no joy, so am including all of my code to help explain in greater detail.
EventCalendarController.cs
using iehp.EventCalendar.Models;
using Sitecore;
using Sitecore.Data;
using Sitecore.Data.Items;
using Sitecore.Mvc.Controllers;
using System.Linq;
using System.Web.Mvc;
namespace iehp.Controllers
{
public class EventCalendarController : SitecoreController
{
public ViewResult EventCalendarCtrl()
{
//read in config file & get parentGuid value
var parentGuidValue = Sitecore.Configuration.Settings.GetSetting("eventCalendarFolderGuid");
//init Sitecore db
Database database = Context.Database;
var model = new EventViewModel();
model.Item = database.GetItem(parentGuidValue);
model.Children = model.Item.Children.ToList();
return View("/Views/Components/EventCalendarCtrl.cshtml", model);
}
}
}
EventCalendarCtrlModel.cs
using Sitecore.Data.Items;
using System.Collections.Generic;
namespace iehp.EventCalendar.Models
{
public class EventViewModel
{
public Item Item { get; set; }
public List<Item> Children { get; set; }
}
}
EventCalendarCtrl(partial view)
#model iehp.EventCalendar.Models.EventViewModel
<div class="col-12"><h4>Upcoming Events</h4></div>
<div class="col-12 text-right">load more >> </div>
<div class="col-24">
<ul id="eventsTab" class="nav nav-tabs nav-fill">
<li class="nav-item">
#Html.ActionLink("Community", "", new { id = "Community" }, new { #class = "nav-link" + #ViewBag.Tab == "Community" ? " active" : "" })
</li>
<li class="nav-item">
#Html.ActionLink("Health", "", new { id = "Health" }, new { #class = "nav-link" + #ViewBag.Tab == "Health" ? " active" : "" })
</li>
</ul>
</div>
Community.cshtml(view)
#using Sitecore.Data.Fields
#using Sitecore.Data.Items
#using Sitecore.Mvc
#using Sitecore.Resources.Media
#model iehp.EventCalendar.Models.EventViewModel
#{
ViewBag.Tab = "Community";
}
#Html.Partial("EventCalendarCtrl")
<div id="Community" class="card-deck">
#foreach (var child in Model.Children)
{
Item item = Sitecore.Context.Item;
ImageField imgField = ((ImageField)child.Fields["Image"]);
<div class="card" style="margin-right:20px;">
<img class="card-img-top" src="#MediaManager.GetMediaUrl(imgField.MediaItem)" />
<div class="card-body">
<p class="card-text">#Html.Sitecore().Field("Description", child)</p>
<p class="date-time"><strong>Event Date:</strong> #Html.Sitecore().Field("Event Date", child)</p>
</div>
</div>
}
</div>
thanks!
Using partial view would be something like this
_CommunPage.cshtml:
#model iehp.EventCalendar.Models.EventViewModel
<div class="col-12"><h4>Upcoming Events</h4></div>
<div class="col-12 text-right">load more >> </div>
<div class="col-24">
<ul id="eventsTab" class="nav nav-tabs nav-fill">
<li class="#(ViewBag.Tab == "Community" ? "nav-item active" : "nav-item")">
#Html.ActionLink("Community", "", new { id = "Community" }, new { #class = "nav-link")
</li>
<li class="#(ViewBag.Tab == "Health" ? "nav-item active" : "nav-item")">
#Html.ActionLink("Health", "", new { id = "Health" }, new { #class = "nav-link")
</li>
</ul>
</div>
Community.cshtml:
#{
ViewBag.Title = "Community Page Tile";
ViewBag.Tab = "Community";
}
#Html.Partial("_CommunPage")
Html for the Community page....
Health.cshml:
#{
ViewBag.Title = "Health Page Tile";
ViewBag.Tab = "Health";
}
#Html.Partial("_CommunPage")
Html for the Health page....

How to update EngineContext.Current.Resolve<StoreInformationSettings>().ResponsiveDesignSupported after upgrade to nopcommerce 3.9

We try to upgrade an existing nopcommerce application from 3.40 to 3.90.
All steps from http://docs.nopcommerce.com/display/en/Upgrading+nopCommerce are followed.
In all web.config files from custom Themes and Custom Plugins The MVC version is updated from System.Web.Mvc, Version=5.0.0.0, to System.Web.Mvc, Version=5.2.3.0.
Now we get the folowing error in our custom Theme.
Compiler Error Message: CS1061: 'Nop.Core.Domain.StoreInformationSettings' does not contain a definition for 'ResponsiveDesignSupported' and no extension method 'ResponsiveDesignSupported' accepting a first argument of type 'Nop.Core.Domain.StoreInformationSettings' could be found (are you missing a using directive or an assembly reference?)
There seems to be no ResponsiveDesignSupported property in the StoreInformationSettings.
Is there a way in nopcommerce 3.90 to get the ResponsiveDesignSupported setting?
Below some code
#model TopMenuModel
#using Nop.Core.Domain
#using Nop.Core.Infrastructure
#using Nop.Web.Models.Catalog;
#{
var isRtl = this.ShouldUseRtlTheme();
var supportResponsive = EngineContext.Current.Resolve<StoreInformationSettings>().ResponsiveDesignSupported;
}
#helper RenderCategoryLine(CategorySimpleModel category, int level, bool responsiveMobileMenu)
{
<li>
<a href="#Url.RouteUrl("Category", new { SeName = category.SeName })">#category.Name
#if (category.NumberOfProducts.HasValue)
{
<text> </text>#T("Categories.TotalProducts", category.NumberOfProducts.Value)
}
</a>
#{
var levelClass = "";
if (level == 0)
{
levelClass = "firstLevel";
<div class="top-menu-triangle"></div>
}
if (category.SubCategories.Count > 0)
{
if (responsiveMobileMenu)
{
<span class="expand"> </span>
}
<div class="sublist #levelClass">
<ul>
#foreach (var subCategory in category.SubCategories)
{
#RenderCategoryLine(subCategory, level + 1, responsiveMobileMenu)
}
</ul>
</div>
}
}
</li>
}
<ul class="top-menu">
#Html.Widget("header_menu_before")
#if (Model.Categories.Count > 0)
{
<li><i class="fa fa-home fa-lg"> </i></li>
foreach (var category in Model.Categories)
{
#RenderCategoryLine(category, 0, false)
}
}
else
{
//no categories to display? in this case let's diplay some default menu items (should we?)
<li>#T("HomePage")</li>
if (Model.RecentlyAddedProductsEnabled)
{
<li>#T("Products.NewProducts")
</li>
}
<li>#T("Search") </li>
<li>#T("Account.MyAccount")</li>
if (Model.BlogEnabled)
{
<li>#T("Blog")</li>
}
if (Model.ForumEnabled)
{
<li>#T("Forum.Forums") </li>
}
<li>#T("ContactUs")</li>
}
#Html.Widget("header_menu_after")
</ul>
<script type="text/javascript">
$('li', '.top-menu').on('mouseenter', function () {
$('a', $(this)).first().addClass('hover');
if (!$(this).parent().hasClass('top-menu')) {
var width = $(this).innerWidth();
$('.sublist', $(this)).first().css('#(isRtl ? "right" : "left")', width + 15);
}
$('.sublist', $(this)).first().addClass('active');
$('.top-menu-triangle', $(this)).addClass('active');
});
$('li', '.top-menu').on('mouseleave', function () {
$('a', $(this)).first().removeClass('hover');
$('.sublist', $(this)).first().removeClass('active');
$('.top-menu-triangle', $(this)).removeClass('active');
});
</script>
#if (supportResponsive)
{
<div id="mob-menu-button">
<a href="">
<span class="icon"><span class="line"></span><span class="line"></span><span class="line"></span></span>
#{
var responsiveMenuTitle = Model.Categories.Count > 0 ? T("Categories") : T("Menu");
}
<span>#responsiveMenuTitle</span>
</a>
</div>
<ul class="mob-top-menu">
#Html.Widget("mob_header_menu_before")
#if (Model.Categories.Count > 0)
{
foreach (var category in Model.Categories)
{
#RenderCategoryLine(category, 0, true)
}
}
else
{
//no categories to display? in this case let's diplay some default menu items (should we?)
<li>#T("HomePage")</li>
if (Model.RecentlyAddedProductsEnabled)
{
<li>
#T("Products.NewProducts")
</li>
}
<li>#T("Search") </li>
<li>#T("Account.MyAccount")</li>
if (Model.BlogEnabled)
{
<li>#T("Blog")</li>
}
if (Model.ForumEnabled)
{
<li>#T("Forum.Forums") </li>
}
<li>#T("ContactUs")</li>
}
#Html.Widget("mob_header_menu_after")
</ul>
<script type="text/javascript">
$('a', $('#mob-menu-button')).toggle(function() {
$('.mob-top-menu').addClass('show');
},
function() {
$('.mob-top-menu').removeClass('show');
}
);
$(function($) {
$('.mob-top-menu .expand').click(function() {
var parent = $(this).parent();
if (parent.hasClass('active')) {
$(".sublist:first", parent).hide(300);
parent.removeClass('active');
} else {
$(".sublist:first", parent).show(300);
parent.addClass('active');
}
});
});
</script>
}
since version 3.70 the ResponsiveDesignSupported setting is no longer available, and nop supports responsive themes out of the box, if you want to turn off or turn on responsive designs in a theme, it should be done inside your theme itself by jquery, css.
Responsive design supported option is removed from nopCommerce 3.6 onward.
If you have purchased a custom theme from any vendor please get the theme for your nopCommerce 3.9 version.

Wrong tab opening with razor

I have two tabs,one is "Compras" and other "Fiscal",when i open the aplication, if the users has the role "68" is should open the tab fiscal, otherwise open "Compras",the problem is that the currently way i`m doing when i open the tab Fiscal comes selected correct but it opens the tab Compras.
I check here the permission of the user.
ViewBag.isFiscal = false;
if (Web.Security.CustomPrincipal.CurrentUser().IsAuthenticated)
{
if (Web.Security.CustomPrincipal.CurrentUser().IsInRole("68"))
{
ViewBag.isFiscal = true;
}
}
And here i try to open the tab Fiscal:
<ul class="nav nav-tabs">
<li class="#(ViewBag.isFiscal == false ? "active" : "" )">
<a data-toggle="tab" href="#compras" data-etapa="78">Compras</a>
</li>
<li class="#(ViewBag.isFiscal == true ? "active" : "" )">
#if (Model != null && Model.IdTemplate > 0)
{
<a data-toggle="tab" href="#fiscal" data-etapa="80">Fiscal</a>
}
else
{
Fiscal
}
</li>
</ul>
But when i open with a user that has role 68 it opens like this:
It is marked Fiscal,but the content of the form is from the form Compras,the correct Fiscal is this:
Someone knows what i`m missing?
I found the solution.
I was putting the tag active only in tab Compras,and now i do a verification to put the tag active in Compras or fiscal
<div id="compras"class="tab-pane #( (bool)Session["isFiscal"] == false ? "active" : "" )">
#*<div id="compras" class="tab-pane active">*#
#using (Html.BeginForm("Index", "Home", FormMethod.Post, new { #class = "form-horizontal form-compras", id = "frmSaveCompras", action = string.Format("{0}/home/index", pathRoot) }))
{
#Html.Partial("_abaCompra", Model, ViewData)
}
</div>
#if (Model != null && Model.IdTemplate > 0)
{
<div id="contabil" class="tab-pane">
#using (Html.BeginForm("AbaContabil", "Home", FormMethod.Post, new { #class = "form-horizontal form-contabil", id = "frmSaveContabil", action = string.Format("{0}/home/AbaContabil", pathRoot) }))
{
#Html.Action("AbaContabil", "home", new { id = Model.IdItem, partial = (bool)ViewBag.partial, hash = (string)ViewBag.hash })
}
</div>
<div id="fiscal" class="tab-pane #((bool)Session["isFiscal"] == true ? "active" : "" )">>
#Html.Action("AbaFiscal", "home", new { id = Model.IdItem, partial = (bool)ViewBag.partial, hash = (string)ViewBag.hash })
</div>
}

asp.net mvc create dynamic tabs

<div id="tabs">
<ul id="editorRows">
#foreach (var item in (IEnumerable<WebSiteLanguage>)ViewBag.WebSiteLanguages)
{
#*<li><a href=#Url.Action("PageLanguageWiseContent", "Page", new { LangId = item.LangId })><span>#item.Language.LangName</span></a></li>*#
<li><span>#item.LangName</span></li>
}
</ul>
#foreach (var item in (IEnumerable<WebSiteLanguage>)ViewBag.WebSiteLanguages)
{
<div id="#item.LangName">
#{
Html.RenderAction("PageLanguageWiseContent",new { LangId = item.LangId });
}
</div>
}
</div>
how can i create tabs in one loop? Any other approach which will allow me to use only one loop?

Variable in partial view not accessible in layout view

I have a partial view called _Menu.cshtml using the code below. While using a partial view, the variable "menus" cannot be found by a code routine in my main _Layout.cshtml view. If I copy the _Menu.cshtml code into my _Layout.cshtml my routine works perfectly. I know my partial view _Menu.cshtml is accessible to _Layout.cshtml because if I put "hello world" in the partial view it displays in the _Layout.cshtml as expected.
Just for reference my login/logout sets the session["MyMenu"] to null. So I am using a session cache for the menu for speed.
Here is my partial view _Menu.cshtml ::
#{
var menus = new[]
{
new { LinkText="Home", ActionName="Index",ControllerName="Home",Roles="All" },
new { LinkText="About", ActionName="About",ControllerName="Home",Roles="Anonymous" },
new { LinkText="Contact", ActionName="Contact",ControllerName="Home",Roles="Anonymous" },
new { LinkText="Dashboard", ActionName="Index",ControllerName="Admin",Roles="Anonymous" },
new { LinkText="Administration", ActionName="GetUsers",ControllerName="Admin",Roles="Administrator" },
new { LinkText="My Profile", ActionName="GetDealerInfo",ControllerName="Dealer",Roles="Dealer,PublicUser" },
new { LinkText="Products", ActionName="GetProducts",ControllerName="Product",Roles="Dealer,Administrator" },
new { LinkText="Search", ActionName="SearchProducts",ControllerName="Product",Roles="PublicUser,Dealer,Administrator" },
new { LinkText="Purchase History", ActionName="GetHistory",ControllerName="Product",Roles="PublicUser" },
};
}
Here is my partial view _Layout.cshtml ::
<nav>
#if (System.Web.HttpContext.Current.Session["MyMenu"] == null)
{ System.Web.HttpContext.Current.Session["MyMenu"] = Html.Partial("~/Views/Shared/_Menu.cshtml"); }
#System.Web.HttpContext.Current.Session["MyMenu"]
</nav>
<ul id="menu">
#*<li>#Html.ActionLink("Home", "Index", "Home")</li>
<li>#Html.ActionLink("About", "About", "Home")</li>
<li>#Html.ActionLink("Contact", "Contact", "Home")</li>
<li>#Html.ActionLink("Codes", "Index", "xRefCodes")</li>*#
#if (HttpContext.Current.User.Identity.IsAuthenticated)
{
String[] roles = Roles.GetRolesForUser();
var links = from item in menus
where item.Roles.Split(new String[] { "," }, StringSplitOptions.RemoveEmptyEntries)
.Any(x => roles.Contains(x) || x == "All")
select item;
foreach (var link in links)
{
#: <li> #Html.ActionLink(link.LinkText, link.ActionName,link.ControllerName)</li>
}
}
else{
var links = from item in menus
where item.Roles.Split(new String[]{","},StringSplitOptions.RemoveEmptyEntries)
.Any(x=>new String[]{"All","Anonymous"}.Contains(x))
select item;
foreach ( var link in links){
#: <li> #Html.ActionLink(link.LinkText, link.ActionName, link.ControllerName)</li>
}
}
</ul>

Resources