107
votes
1answer
35k views

ASP.Net MVC 3 Razor: Include js file in Head tag

I'm trying to figure out the proper razor syntax to get a js file for a particular *.cshtml to be in the head tag along with all the other include files that are defined in _Layout.cshtml Thank you, ...
18
votes
9answers
6k views

asp.net-mvc: razor '@' symbol in js file

I have a .csHtml-razor file with a javascript function that uses the @Url.Content C# function inside for the ajax URL. I want to move that function to a .js file referenced from my view. The problem ...
29
votes
1answer
19k views

Razor Syntax and Javascript

As a test I'm converting a proof-of-concept app we've written from Web Forms to Razor, simply so we can evaluate it. I've run into one problem so far that's making my head hurt..generating ...
57
votes
5answers
11k views

Populate a Razor Section From a Partial

My main motivation for trying to do this is to get Javascript that is only required by a partial at the bottom of the page with the rest of the Javascript and not in the middle of the page where the ...
12
votes
3answers
3k views

Share constants between C# and Javascript in MVC Razor

I'd like to use string constants on both sides, in C# on server and in Javascript on client. I encapsulate my constants in C# class namespace MyModel { public static class Constants { ...
5
votes
3answers
9k views

Ajax call Into MVC Controller- Url Issue

I've looked at the previously-posted jQuery/MVC questions and haven't found a workable answer. I have the following JavaScript code: $.ajax({ type: "POST", url: ...
3
votes
2answers
5k views

Create pdf with wkhtmltopdf and rendering javascript

I'm attempting to create a PDF of a javascript chart that I have in a model window (my chart is a combination of javascript and css in an .aspx view). The only thing in the rendered PDF file is the ...
3
votes
2answers
9k views

ASP.NET MVC - Returning a PartialView to Ajax along with another object

I am writing a single page ajax app with ASP.NET MVC - making heavy use of jQuery. I do something similar to the following throughout the app: JS: $.ajax({ type: "GET", url: ...
3
votes
1answer
6k views

Auto refresh in ASP.NET MVC

In webforms I'd do <script type="text/JavaScript"> function timedRefresh(timeoutPeriod) { setTimeout("location.reload(true);", timeoutPeriod); } </script> ...
5
votes
1answer
2k views

MVC3 unobtrusive validation: how to remove/re-attach validation from a group of elements?

Here's the use case: I have this long form with group of field that only becomes visible if the user makes a certain selection in one of the visible inputs. Reading Brad Wilson's post on the subject ...
8
votes
3answers
16k views

Conditional Compilation is turned off in Razor?

I've got a c# foreach loop that Is outputting some javascript to initialize some progress bars on my razor view. @foreach (var item3 in Model) { @:$("#[email protected]").wijprogressbar({ ...
23
votes
3answers
20k views

Call MVC 3 Client Side Validation Manually for ajax posts

I am creating an MVC 3 web application. I want to use Data Annotations on my entity class and then use onobtrusive client side validation before making a post back to the server. This works fine when ...
16
votes
4answers
2k views

Timezone Strategy

I am building a MVC 3 application where the users may not be in the same time zone, so my intent was to store everything in UTC and convert from UTC to local time in the views and localtime to UTC on ...
7
votes
3answers
14k views

MVC3 Client side validation not working

I'm using MVC3 with Razor. I've included the following in my _Layout.cshtml: <script src="@Url.Content("~/Scripts/jquery.validate.js")" type="text/javascript"></script> <script ...
6
votes
3answers
5k views

Valums file-uploader doesn't work under Internet Explorer 9

Valums file-uploader (now called Fine Uploader) doesn't work under Internet Explorer 9 but wors fine under Chrome. So under IE it shows the name of the file and button CANCEL and no % of uploading. ...

1 2 3 4 5 8
15 30 50 per page