asp.net-mvc

Problem in No script tag

Im placing no script tag on my master page that if a user dont have javascript enabled or its browsers doesnt support javascript it redirect to a specific view. im using this code <noscript> <% Response.Redirect("../UserLogin/Error"); %> </noscript> but the problem is its redirecting me everytime i open the page although my j...

in c#, how do i convert this data structure into Json

In C# i have an array of Calendar objects each Calendar object has an array of CalendarEvent objects each CalendarEvent object has a Date and Name property i want to convert this to Json object but i want to change the data structure a bit so in the json object a calendar is an array of dates and an array of names (breakdown the Calen...

Is this a 'hack', and if so is there a better way to determine which ActionResult to return?

I have an A - Z directory 'widget' that I have on every page. If the user is on the home page and they click something in the directory, I want to load up the directory page with the corresponding result loaded. But if the user is on the directory page and they click something, I want to asynchronously load the result without doing a pag...

Is there a correct way of using the HtmlHelper within a JavaScript function?

I'm writing a jQuery grid plugin and I've designed it so it works independently from the language being used. The following is the basics of how my plugin is assigned: $("#grid").grid({ enablePager: true, dataPath: "Movement/GetGridPage", columns: { Edit: { title: "", cellCallback: editButtonCallBack, width:"16px" }...

Custom Model Binder for DropDownList not Selecting Correct Value

Hi, i've created my own custom model binder to handle a Section DropDownList defined in my view as: Html.DropDownListFor(m => m.Category.Section, new SelectList(Model.Sections, "SectionID", "SectionName"), "-- Please Select --") And here is my model binder: public class SectionModelBinder : DefaultModelBinder { public override ...

asp.net mvc routing with optional starting parameter

I'm starting a port of an existing ASP.NET Web Forms CMS to ASP.NET MVC and want to get the routing right from the start. Note: it isn't important to have the exact same URL structure. I think this answer is close to what I'm looking for but would like some additional input should anyone have it. The current URL struction is like: ...

Wordpress with ASP.NET MVC

I have Wordpress in a subfolder in my site named blog. When I goto the url of my site /blog/ I get the error 404 - File or directory not found. The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable. This use to show the default theme and an empty blog. I think it may be a routing...

How do I reference/access a Strongly Typed Html Helper in jquery?

I've mostly worked in MVC1. I'm now working with some MVC2 code. I have fields with Strongly Typed Html Helpers like: <div class="editor-field"> <%: Html.TextBoxFor(model => model.Contract.client_name)%> <%: Html.ValidationMessageFor(model => model.Contract.client_name) %> </div> How do I acce...

Asp.Net Mvc highlighting current page link technique?

Hello all. I need to highlight active link in the menu. My menu is in the master page by the way. I'm looking for the best way to implement this? Any ideas? ...

Update content with AJAX every X minutes at same time for several users

So I have an area on my page that I would like to update every 10 minutes. Right now, I'm using this code: var refresh = setInterval(refreshArea, 600000); But this updates on the client side, so if 100 different users are looking at the page, the content will update at 100 different times. I'd like for the content to update every 10...

stackexchange facebook and twitter buttons

I have just seen the buttons on StackExchange sites for Facebook and Twitter status updates. I was wondering how SE is implementing this? I found this excellent post http://amirrajan.net/Blog/asp-mvc-and-facebook-single-sign-on that shows how to sign in and out of facebook in MVC. But SE didn't even ask me to sign in, I was logged int...

Display time padded how Stackoverflow and Facebook do - C#

I have a ASP.NET MVC 2 app I am building and users are allowed to post data in certain sections. I would like to display the "Posted At" in the same format that Stackoverflow and Facebook do. i.e. On this site when I post this question it will display "asked 3 seconds ago" then "asked 3 mins ago" and after a few day it will display the...

[ASP.NET MVC] Cache CSS and JS files

Hi all, When I refresh my website in less than 2-3 minutes, Firebug shows these nice requests: 1. /core.css 304 Not modified 2. /core.js 304 Not modified 3. /background.jpg 304 Not modified BUT when I refresh after >3 minutes, I get: 1. /core.css 200 OK 2. /core.js 200 OK 3. /background.jpg ...

ASP.NET MVC2 Apps - Extending App

Here is my problem for using mvc2, I cant find a silver bullet fix for this. I have a standard mvc app which has following views, controllers and Models View WorkOrders Estimates Model WorkOrder Estimate Controller WorkOrderController EstimateController I recently got a client who wants this app with little customization. I am sti...

Is it possible to automatically prefix all table names in SQL Server and in LINQ to SQL?

I'm working on a few ASP.NET MVC projects which all require database functionality. Unfortunately, my hosting provider only gives me two SQL Server databases to work with, so I want to put the tables of multiple projects into a single database. However, some of my tables are similarly named, so I might run into some issues. Thus, I'm tr...

Throw Exception if record is a foreign key in another table

UPDATE: Probably should model my database to my objects correctly first! Found this tutorial http://www.codeproject.com/KB/linq/linqtutorial.aspx so should probably ignore this question! Hi All, Apologies if this already has a thread but I cant seem to find the answer I am looking for. I have an object Communication Type: [Table(Name ...

asp.net mvc dynamic render partials

I'm working on an asp.net mvc project, I have a request to render html controls dynamically based on the data type from db, for example: i have 2 record in db; id | type | value =========================== 1 | charactor | 1 2 | number | 2 in the html side, i want generate these 2 controls differently, for ...

Can you convert C# dictionary to Javascript associative array using asp.net mvc Json()

I recently asked this question, but after some of the responses and some research, i wanted to change what i was actually asking. i have seen a number of blog posts about sending associative arrays from javascript to C# controller action but i want the opposite. I want to return json to a client as a dictionary (from my research the ja...

Why is my ASP.NET MVC 2 application reporting "The resource cannot be found."?

I deployed my first ASP.NET 4.0/MVC 2 application onto a staging and test server. The problem is that when I browse to the application I just get the ASP.NET 404 "The resource cannot be found." page. The application was written using: Visual Studio 2010 Premium Target Framework: .NET 4.0 ASP.NET MVC 2.0 The application is deployed o...

ASP.NET MVC Ajax.BeginForm doesn't work

Hi, I have that code: <script src="../../Scripts/MicrosoftMvcAjax.debug.js" type="text/javascript"></script> <script src="../../Scripts/MicrosoftAjax.debug.js" type="text/javascript"></script> <script type="text/javascript"> function loginOK() { var item = document.getElementById('statusLabel'); item.innerHTML =...