Menu
  • HOME
  • TAGS

MVC5 MvcSiteMapProvider to display full sitemap

Tag: twitter-bootstrap-3,asp.net-mvc-5,mvcsitemapprovider

I successfully installed MvcSiteMapProvider, and got the breadcrumbs working and customizing the templates to generate Twitter Bootstrap navbar menu. Everything is honky dory. Now I'd like to have a view which sole purpose would be to display the whole sitemap hierarchy (in a tree structure, nodes would be clickable).

I've found traces of old ASP.NET sitemap solution to XSLT transform the sitemap XML file. That's not only a dead-end because it's old and doesn't look like a good idea, but I also take advantage of the annotation feature of MvcSiteMapProvider.

I don't use external DI framework.

I turn to here because my search attempts came out empty. I guess I could do something like the bootstrap navbar customization, creating some templates. But I'm sure I'm not the first one and I'd be happy to see some working code if there any out there.

Best How To :

Per the documentation:

Html.MvcSiteMap().SiteMap() - Can be used to generate a list of all pages in your sitemap

If that doesn't meet your needs, you could always build your own custom HTML helper to display the SiteMap per your requirements. Have a look at this answer for a demo showing how to create Next and Back links according to the document outline of the SiteMap.

Inherited Property of Model is always returning Null Value

c#,asp.net,asp.net-mvc,asp.net-mvc-3,asp.net-mvc-5

You radio button group is not inside the <form> tags so its value is not sent when the form is submitted. You need to move the radio buttons to inside the form (in the partial) and remove the hidden input for property ReportName. If this is not possible you could...

Bootstrap Justified Nav Bar not collaspsing correctly

css,twitter-bootstrap-3

Hi you can do something like this to prevent wrapping .nav > li > a { white-space: nowrap; } This will prevent to break words...

Random opening tabs/pills - bootstrap 3

javascript,css,wordpress,twitter-bootstrap-3

use this code : var items = $('[data-toggle=pill]'); var i = parseInt(Math.floor(Math.random()*items.length)); $('#tabs a:eq(' + i + ') ').tab('show'); ...

Inconsistent display on IE & Firefox

html,css,internet-explorer,firefox,twitter-bootstrap-3

Adding clearfix divs as explained here helped to resolve the display issues. Fix applicable in my scenario was adding <div class="clearfix"></div> after the four items of the first row...

Bootstrap text-danger with form-inline not aligned

css,twitter-bootstrap-3,jqbootstrapvalidation

With the various answers I got. I managed to get it working. Here is the final code. <form> <div class="row"> <div class="col-sm-6 text-center"> <div class="form-group form-group-lg"> <label class="sr-only" for="name">Full Name</label> <input class="form-control" type="text" id="formGroupInputLarge" placeholder="Full name" name="name" required data-validation-required-message="Please enter your full name."> <div class="help-block text-danger"></div> </div> </div> <div...

How to augment actionlink with route values at runtime with JavaScript in ASP.NET MVC 5?

javascript,asp.net,asp.net-mvc,asp.net-mvc-5,asp.net-mvc-routing

I'm not sure this is the best way of doing this, but I'll provide you with my solution to this problem. The main idea is to generate the link with all required parameters and format the href with javascript, like string.Format in c#. Generate the link: @Html.ActionLink("Link", "action", "controller", new...

How can I make my icon stay in the center of my accordion header?

html,css,twitter-bootstrap-3

Add a negative top margin to your icon. .hide-details-sk-p .icon-sk-p-r { margin-top: -5px; } JSfiddle...

how to make a loop and if statement that loops through a different groups of radio buttons (javascript)

html,loops,twitter-bootstrap-3,radio-button

Here, take a look at this demo boootply. Since you're using Bootstrap, jQuery should already be part of your page. Here's the relevent code: $(document).ready(function(){ $('#submitBtn').click(function(e){ e.preventDefault(); if($('li.option :radio:checked').length == $('li.option').length){ // enter code here to submit your form alert('submitted'); }else{ alert('Please answer all questions'); } }); }); And the...

Convert SQL to linq statement

c#,linq,asp.net-mvc-5

Just use Any(), which will return a boolean, true if your query returns anything, else false. var result =(from a in _applicationRepository.GetList(a => a.ID == applicationId) from r in _roleRepository.GetList(r => r.ApplicationId == a.ID && r.Name == rolename) from au in _authorizationRepository.GetList(au => au.ApplicationId == a.ID && r.ID == au.RoleId)...

Produce different serialized JSON for a given class in different scenarios

c#,json,serialization,asp.net-mvc-5,json.net

I finally went with a mix of Wrapper classes and the methodology suggested by Raphaël Althaus: use Wrappers where some amount of sophistication may be required and use Raphaël's suggestion when simplicity will do. Here's how I am using wrappers (intentionally left out null checks): public class Entity1View1 { protected...

How to use ajax to post json string to controller method?

jquery,asp.net-mvc,visual-studio-2013,asp.net-mvc-5

Your action method is expecting a string. Create a javascript object, give it the property "data" and stringify your data object to send along. Updated code: $.ajax({ type: 'post', dataType: 'json', url: 'approot\Test', data: { "json": JSON.stringify(data) }, success: function (json) { if (json) { alert('ok'); } else { alert('failed');...

Web API Basic Auth inside an MVC app with Identity Auth

c#,authentication,asp.net-web-api,asp.net-mvc-5

I us a filter attribute to adorn the actions i wanted to expose to Simple Auth. I cant remember where i got this code from (probably stackoverflow i just don't have the link so i cant claim credit for it) public class BasicHttpAuthorizeAttribute : AuthorizeAttribute { protected override bool IsAuthorized(HttpActionContext...

Prevent bootstrap 3 tab from stacking when window is resized (made smaller)

html5,css3,twitter-bootstrap-3

Your tabs breakdown after the width is within 767px, so you can use the below CSS hack. @media (max-width: 767px) { .nav-tabs.nav-justified > li { float: left; width: 50%; } } Bootply...

Bootstrap Hovering

javascript,twitter-bootstrap-3

Possible without javascript: http://jsfiddle.net/ap8vT/284/ .wrapper:hover .default { opacity: .5; } .wrapper .default:hover { opacity: 1; } You can define those styles whatever you want....

span is not inline with input using bootstrap 3

html,css,twitter-bootstrap-3

All what you need to do just change the span to label and have it above the div that holds inputs like so in the code below: <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet" /> <form name="productForm" class="form-horizontal"> <div class="form-group"> <label for="number" class="col-sm-2 control-label">Number</label> <div class="col-sm-10"> <input...

Knockout js unable to bind data using observableArray

knockout.js,asp.net-mvc-5

self.Employees.push(data); should be self.Employees(data);

How to get routevalues from URL with htmlhelpers or JavaScript?

javascript,asp.net,asp.net-mvc,asp.net-mvc-5,asp.net-routing

To write server side code to be processed by razor engine, you have to prepend your statement with @. That will only work if that Javascript is embedded on the view. You can also do it with Javascript. Something like this should do the trick var urlParts = location.href.split('/'); var...

how to align column to the right?

angularjs,css3,twitter-bootstrap-3

You can add ' text-right to your <div class="col-md-6 form-group"> please see here http://plnkr.co/edit/rUAdxLJ6ExKZYFbkveuC?p=preview and if you want to have column for 50% of screen even on small devices change col-md-6 to col-xs-6 http://plnkr.co/edit/RxPx0zzT5YmodepQ3zIj?p=preview...

How do I properly send __RequestVerificationToken with an ajax request in MVC5

ajax,asp.net-mvc,asp.net-mvc-5

x = $.post(window.location, {data: $('#editDrinkForm').serialize()}) is wrong. Do this: x = $.post(window.location, data: $('#editDrinkForm').serialize()) (some credit to stephen's comment)...

Bootstrap 3 collapsed menu not working on mobile screens

jquery,css,twitter-bootstrap,twitter-bootstrap-3

1mjp Hi there, have a look at the Fiddle here. Or the snippet below. It only has standard Bootstrap css/js. And your menu, which works fine, no problem like in your website. Have a look to see if you have some js closing the link when clicked. I think you...

Content section overlap footer

html,css,twitter-bootstrap,css3,twitter-bootstrap-3

remove - position: absolute for footer create wrapper for page content to push down footer html, body { height: 100%; } body { margin: 0; padding: 0; } .wrapper { min-height: 100%; height: auto; /* Negative indent footer by its height */ margin: 0 auto -60px; /* Pad bottom...

How to append Urls in angular routing?

asp.net,angularjs,asp.net-mvc-5,angularjs-ng-repeat,angular-ui-router

You need to change your $routeProvider.when url option, that will accept two parameter one would be albumType & other would be alubmName. You that you could get those values in your b1Ctrl using $routeParams service. Markup <li ng-repeat="album in albums"> <a ng-href="/albums/{{alubm.type}}/{{album.name}}">{{album.name}}</a> </li> Code when('/albums/:albumType/:albumName', { templateUrl: 'AlbumsList.html', controller: 'b1Ctrl'...

MVC: after export to excel, index action result is not getting called

asp.net-mvc-5,export-to-excel

You can't do that I'm afraid, once you have sent the header for the download, you can't then send another set of headers to do the redirect. There is a technique mentioned in this blog post which you can alter to do a redirect when a cookie appears from the...

Best approach to upgrade MVC3 web app to MVC5?

c#,.net,asp.net-mvc,asp.net-mvc-5

There's a handy documented guide by Rick Anderson which he wrote to upgrade from MVC4, the same applies to you with the exception of the fact that the "Old version" of DLLs he mentions will be different to the ones that you will have, but the outcome will still be...

MVC 5 OWIN login with claims and AntiforgeryToken. Do I miss a ClaimsIdentity provider?

asp.net-mvc,asp.net-mvc-4,razor,asp.net-mvc-5,claims-based-identity

Your claim identity does not have ClaimTypes.NameIdentifier, you should add more into claim array: var claims = new List<Claim> { new Claim(ClaimTypes.Name, "Brock"), new Claim(ClaimTypes.Email, "[email protected]"), new Claim(ClaimTypes.NameIdentifier, "userId"), //should be userid }; To map the information to Claim for more corrective: ClaimTypes.Name => map to username ClaimTypes.NameIdentifier => map...

MVC route attribute no controller

asp.net-mvc,asp.net-mvc-5,asp.net-mvc-routing

Ok so ranquild's comment pushed me in the right direction. In my route config, I had the default route of routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } ); So that my homepage would still work on the url with...

MvcSiteMapProvider - Enhanced bootstrap dropdown menu

c#,twitter-bootstrap,asp.net-mvc-5,mvcsitemapprovider,mvcsitemap

node.Descendants should be node.Children Learn the difference on Descendants and Children here, CSS Child vs Descendant selectors (Never mind the post beeing about CSS, this is a generic pattern)...

padding between col-md2 elements

html,twitter-bootstrap,twitter-bootstrap-3

You need to change the .col-md-2 padding values. In the following HTML I added the .little-padding class to use and make the different padding. <div class="container"> <div class="row little-padding"> <div class="col-md-2"> <input mytr="first_name" mytrid="" name="first_name[]" id="first_name" class="form-control" placeholder="First name" type="text"> </div> <div class="col-md-2"> <input mytr="middle_name" mytrid="" name="middle_name[]" id="middle_name" class="form-control" placeholder="Middle...

How to upgrade mvc2 to mvc5?

asp.net-mvc,asp.net-mvc-2,asp.net-mvc-5

I would highly recommend you to create a new empty MVC 5 project, and move all your files there from old MVC 2 project. If you just try to update DLLs its very hard be sure if you updated all DLLs, proj file, nugets, or at least little bit more...

MVC/Razor: Error at Viewbag.Title

c#,asp.net-mvc,razor,asp.net-mvc-5

Ok, the culprit was this: <ul class="list-inline text-center propertyRegionUL"> <li data-marketid="Miami-Dade" class="regionLI @(ViewContext.RouteData.Values["id"].ToString() == "Miami-Dade" ? "active" : "")">Miami Dade</li> <li data-marketid="Fort-Lauderdale" class="regionLI @(ViewContext.RouteData.Values["id"].ToString() == "Fort-Lauderdale" ? "active" : "")">Fort Lauderdale</li> <li data-marketid="West-Palm-Beach" class="regionLI @(ViewContext.RouteData.Values["id"].ToString() ==...

Setting up the page grid using push and pull

html,twitter-bootstrap,css3,twitter-bootstrap-3

Make sure you don't add a period (.) inside of the class attribute. When using push/pull, you need to offset the columns from where they would normally go. Moving them left or right won't change their underlying order in the document flow. So you can do it like this:...

Modal from inside Bootstrap Tabs using Knockout foreach

jquery,twitter-bootstrap,knockout.js,twitter-bootstrap-3

I suggest using a totally different pattern for this. Use one Bootstrap modal at the level of your $root view model. This modal shows data for a root view model observable currentModalItem and is hidden when that observable is null. The modal is activated by setting that observable from inside...

Align column vertically with bootstrap

html,css,twitter-bootstrap,twitter-bootstrap-3,bootstrap

Add a margin to your third column because you have a fixed height. This solution will work. .vertical-align { margin-top: 1.5em; } ...

Twitter Boostrap in Rails

ruby-on-rails,ruby-on-rails-3,ruby-on-rails-4,twitter-bootstrap-3,rubygems

I was able to work it out by moving my project into another directory, preferably into a different folder.

How detailed should your repository be? Testing issues [closed]

c#,unit-testing,asp.net-mvc-5

Welcome to chasing the windmill of 100% test coverage :) You're right, there isn't a ton of value in unit testing a controller method which doesn't actually contain any logic. (Somewhere in the world, Uncle Bob just spilled his coffee.) There is some, though... By explicitly defining the expectations (in...

string.Format is not giving correct output when INR currency symbol (Rs.) come to display

c#,asp.net-mvc-5,devexpress

Your Model.CurrencySymbol string can have some symbols that can be interpreted as format specifier symbols. You can use literal string delimiter ('string', "string") so your currency symbol string will be copied to the result. For example: column.PropertiesEdit.DisplayFormatString = string.Format("'{0}' #,0.00", Model.CurrencySymbol); //Here comes string delimiters: ↑ ↑ Also you can...

aligning controls vertically in bootstrap

css3,twitter-bootstrap-3

Since I understand that you want to create a form with the label next to the field instead of on top of it (as is the default form behaviour of Bootstrap) you should be using the form-inline and form-group classes. This way Bootstrap will align the fields with the labels...

Web API AuthorizeAttribute does not return custom response

c#,asp.net-web-api,asp.net-mvc-5

You should override the OnAuthorization method, that use the IsAuthorized and flushs the response, or force a flush at your method. Makes more sense fill the response where the filter manipulates It.

Put form fields two per line in bootstrap form

html,forms,twitter-bootstrap-3

You have to include the rows in a div. <div class="rows">. <div class="col-md-10"> <div class="form-group"> <legend>1st sth</legend> <div class="row"> <div class="col-md-2"> <select class="form-control" id="select"> <option value="1">1</option> <option value="1">1</option> <option value="1">1</option> </select> </div> <div class="col-md-3"> <input type="text" class="form-control" id="inputName" placeholder="name"> </div>...

Bootstrap switch between class when in tablet or phone viewport

css,twitter-bootstrap,twitter-bootstrap-3

Yes, you will want to use media queries in your css to set the rules differently. If you want the same effect for col-lg-6 you only need to define it in the media query for col-md-6 Keep in mind you only need to define col-sm-6 in your HTML, because it...

LINQ: Searching inside child entities

c#,linq,asp.net-mvc-5

One option would be to use LINQ .Any(): var stringResults = db.Properties.Where(x => x.Address.Contains(id) || /* Other conditions || */ x.BayOptions.Any(g => g.Description.Contains(id))); Here, x.BayOptions.Any(g => g.Description.Contains(id)) will return true if any of the BayOptions values have a description which contains the ID....

how fix this collapsable bootstrap sidebar menu?

css,twitter-bootstrap-3

You are not closing the first "ul" before starting the second one, so bootstrap thinks you have one big unordered list. here is a link to the fix and here: <div class="container body-content"> <div class="row row-offcanvas row-offcanvas-left"> <!-- sidebar --> <div class="col-xs-6 col-sm-3 sidebar-offcanvas" id="sidebar" role="navigation"> <ul class="nav"> <li> <a...

MVC 5 - Validate a specific field on client-side

javascript,jquery,asp.net-mvc,validation,asp.net-mvc-5

After digging around in the source code, I've come to these conclusions. First, the purpose of unobtrusive is to wire up the rules and messages, defined as data- attributes on the form elements by MVC, to jQuery.validation. It's for configuring/wiring up validation, not a complete wrapper around it, so when...

Text going out of the container div

css,twitter-bootstrap,twitter-bootstrap-3,bootstrap

Just add top:0; and left:0; positioning to the CSS: #overlay { background: rgba(0,0,0,0.8); position: absolute; z-index:100; width: 100%; color:#fff; height: 100%; top:0; left:0; } Updated Bootply Update based on your comment: One way to add the padding to the overlay would be to use calc to make the overlay 30px...

Getting users from another AD Domain using PrincipalContext

c#,asp.net,active-directory,asp.net-mvc-5,active-directory-group

You need to use the underlying System.DirectoryServices.DirectoryEntry for the group: var groupEntry = (DirectoryEntry)group.GetUnderlyingObject(); (Note: according to MSDN GetUnderlyingObject() will return a DirectoryEntry, even though the return type is object.) From there you can get the member distinguished names: var memberDistinguishedNames = groupEntry.Properties["member"].Cast<string>(); The users from the other domain are...

Embedding a Silverlight App into a MVC

c#,asp.net-mvc-5,silverlight-5.0

Do you have the Silverlight project added to your MVC project? If you don't you will need to go to your project that is your MVC, right click it and go to properties. Go to silverlight applications then add the project there too. Then try it with your current code...

Convert string value to english word

c#,asp.net-mvc-5

First you need to get the decimal part of the number into a separate integer, then just call your number to words function twice something like this: double value = 125.23; int dollars = (int)value; int cents = (int)((value - (int)value) * 100); Console.WriteLine("{0} dollars and {1} cents", wordify(dollars), wordify(cents));...

In MVC Razor, how can I correctly add querystring parameters to an html.actionlink?

asp.net-mvc,razor,asp.net-mvc-5

The problem arise from the fact that there is no overload as LinkExtensions.ActionLink Method (HtmlHelper, String, String, String, Object) Use the overloaded method LinkExtensions.ActionLink Method (HtmlHelper, String, String, String, Object, Object) @Html.ActionLink((string)item.Student_Name, "Index", "FourCourseAuditDetails", new { filterByStudent = item.Student_Name}, null) Also need to type cast item.Student_Name to string....

Linq Conditional DefaultIfEmpty query filter

c#,linq,asp.net-mvc-5,linq-query-syntax

I solved it by adding the filter after the initial query, checking if the e.PractitionerProfiles were null. var query = from e in _repository.GetAll<Entity>() from u in e.Users where (e.AuditQuestionGroupId != null ? e.AuditQuestionGroupId : 0) == this.LoggedInEntity.AuditQuestionGroupId from p in e.PractitionerProfiles.DefaultIfEmpty() select new { entity = e, user =...

Future plans to consider for asp.net mvc 5.2 web application, with releasing asp.net mvc6 (vnext)

asp.net,asp.net-mvc,asp.net-mvc-5,asp.net-mvc-6,asp.net-mvc-5.2

I would simply recommend following the standard best practice of n-tier architecture and keeping logic related to things like querying a database in class libraries. MVC 6 is drastically different from previous versions, so there's no easy migration. You'll basically need to start a brand new project and move...