FAQ Database Discussion Community


Does HTML Encoding have any cons?

asp.net-mvc,razor,encoding,utf-8,xss
I develop a project on ASP.NET MVC framework. All files and charsets are in UTF-8. I'm using model bindings and in some of my models the display property includes some accented chars or single/double quotes. As Razor engine automatically encodes helpers (ie. DisplayNameFor) the accented chars and quotes are encoded....

Iterating over an ArrayList Always misses 1 entry

c#,asp.net,razor
When iterating over an ArrayList of strings to display on my WebForm using Razor one entry is never actually displayed. The code: <asp:UpdatePanel ID="TweetUpdatePanel" runat="server"> <ContentTemplate> <% ArrayList alList = GetLatest(); %> <ul> <% foreach (string tweet in alList) { %> <li> <asp:Literal ID="thisLiteral" runat="server"></asp:Literal> <% thisLiteral.Text = tweet; %>...

Can't get Editor Template to Work

jquery,asp.net-mvc,razor
I'm trying out editor templates and I can't get it work. I'm working off of this tutorial to try and get a jQuery drop calendar to appear for a DateTime? Can anyone see what I'm doing wrong? I changed my code and tested a TextboxFor and it worked out so...

Rendering “~/bundles/jqueryval”

c#,asp.net-mvc,asp.net-mvc-4,razor
I need your help, I have written this code to render the "~/bundles/jqueryval" The view Code @model workflow.DataHolders.NewCompany <link href="@Url.Content("~/sharedfiles/css/forms/addnew.css")" rel="stylesheet" type="text/css" /> <div id="Add_container"> @if (!ViewData.ModelState.IsValid) { <div id="validationMessage">Please Correct The Errors Below</div> } @using (Html.BeginForm("ValidateAndSignUp", "Accounts", FormMethod.Post)) { @Html.AntiForgeryToken() @Html.ValidationMessage("CompanyName"); <span...

foreach() over List in ViewBag recognizes T as object instead of actual type

c#,asp.net-mvc,razor
I am getting this strange error where Razor would say a property does not exist within an object. I sense I am doing a silly mistake, but I've been battling with this for a while but no luck. Any clues? Controller method: List<Conversations> lConversations = usr.conversations.OrderBy(o => o.active).ThenByDescending(o => o.updated_at).ToList().Select(i...

How do I create an editor template that works with existing data?

c#,asp.net,asp.net-mvc,forms,razor
I created an editor template to display text boxes included in a form. @model WebApplication1.Models.PersonViewModel <input type="text" class="form-control" name="@ViewData.TemplateInfo.HtmlFieldPrefix" value=""/> I simply want to include the 'form-control' class in all my input text boxes used to collect data for this model. public class PersonViewModel { [UIHint("_TextFormControl")] public string FirstName {...

concatenating value to value in c# code — Asp.net MVC

javascript,c#,jquery,asp.net-mvc,razor
I have an anchor and I am assigning the the id to this anchor dynamically <li> <a href="#" name="offset" onclick="return so(this);" data-val="@Math.Round(Convert.ToDouble(ViewBag.lst[0].ca/2))" id='javascript:"[email protected](Convert.ToDouble(ViewBag.lst[0].ca / 2))"'>Last</a> </li> I supposed to get a3 or a4 or a5 because this @Math.Round(Convert.ToDouble(ViewBag.lst[0].ca / 2)) returns numeric value. But I am getting "a+3" or "a+4"....

Transform Querystring to RouteValue in Razor View

c#,jquery,html,asp.net-mvc,razor
I'm stuck with a very basic detail in a view. I want to be able to let the user filter the results in the Index view. To do this I've created a dropdown list, which gets populated thourgh my viewmodel: @using (Html.BeginForm("Index", "Captains", FormMethod.Get)) { <div class="row"> <div class="dropdown"> @Html.DropDownList("Name",...

Getting and passing MVC Model data to AngularJS controller

javascript,asp.net-mvc,angularjs,razor,asp.net-mvc-5
Hey guys so I'm pretty new to AngularJS and I'm at a loss here. Right now my MVC program uses Razor to display all the data in my .mdf database (i.e: @Html.DisplayFor(modelItem => item.LastName) ). However, I want to go mostly Angular. I am trying to use ng-repeat to display...

How to assign C# variable to CSS class variable in ASP.NET MVC ActionLink

c#,css,asp.net-mvc,razor,dynamic-css
In the ActionLink code below, how can I assign a C# string variable to @class in the view in ASP.NET MVC 5? @Html.ActionLink("Manage List", "Index", new { @class = "DynamicClassName" }); I want to replace the static string @class = "DynamicClassName" with something dynamic, similar to @class = @myChangingColorClass //...

Jquery: Change contents of