asp.net-mvc

Linq to SQL, SQL Server 2008 and optimization

I'm designing a large scale web application with about 30 tables, more than 2/3 of which are related to each other. I'm using ASP.NET MVC, Linq to SQL with SQL Server 2008. These tables are meant to hold thousands of records. As a programmer, what should I focus on to help optimize the database and the queries to and from Linq? Do you...

How to throw a SqlException(need for mocking)

Hi I am trying to test some exceptions in my project and one of the Exceptions I catch is SQlException. Now It seems that you can't go new SqlException() so I am not sure how I can throw a exception especially without somehow calling the database(and since it is unit tests it is usually advised not to call the database since it is slow...

How do I produce a JSON string array?

Trying to get a JSON output to work with jqGrid 'userdata' option. The example given in the jqGrid PDF is to produce a JSON result like this; { total: "xxx", page: "yyy", records: "zzz", userdata: {totalinvoice:240.00, tax:40.00}, rows : [ {id:"1", cell:["cell11", "cell12", "cell13"]}, {id:"2",...

Best way to decouple (for parallel processing) a web application's non-immediate processes?

Hello, I'm looking for a good strategy to truly decouple, for parallel processing, my web application's (ASP.NET MVC/C#) non-immediate processes. I define non-immediate as everything that doesn't require to be done right away to render a page or update information. Those processes include sending email, updating some internal statisti...

How to load images defined in css file in .net mvc application deployed to a virtual server

In my View, I have included the css : <link rel="stylesheet" type="text/css" href='<%=Url.Content("~/Content/login.css")%>'/> in login.css, I have #center_left { width:691px; height:190px; background:url(../../images/login_g09.gif); float:left; } This works fine when I use VS 2008 to run the application. Howev...

How Would I Change ASP.NET MVC Views Based on Device Type?

I'm working my way through some ASP.NET MVC reading and I have a web app at work that I'll be migrating from WebForms to MVC. One of the feature requests I expect to get in the process is to have a simplified view returned if the user is coming from a mobile device. I can't quite see where the best place is to implement that type of ...

Is Response.Write in ASP.NET views a bad idea?

Most of my company's web programming background is PHP, so ASP.NET MVC was a logical choice for our newest web application that also needed to work as a back-end to a separate Winforms app. However, we keep finding ourselves going down the road we typically followed in php - echoing lots of tags for conditional output. Is this a bad id...

asp.net mvc - obtain values from a bunch of inputs selectively

I have a bunch of text inputs on my page (HTML.TEXTBOX, generated through for loop), and I want to read their values and commit to database only when user has modified something in those textboxes. What would be a proper way to do that? (Do you think it may make more sense to commit the entire thing to database if number of textboxes ...

Include CSS file in view

In my view, I have included the Master page as follows: <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Mall.Master" Inherits="System.Web.Mvc.ViewPage<DomainModel.Entities.Seller>" %> And in my Mall.master file, I add a link to include a general css file <link rel="Stylesheet" href="../../Content/MallMast...

ASP.Net MVC Unwanted Caching Issue

I've got an issue with an ASP.Net MVC project in that on most of my edit screens if I make a change, save it then go back into my edit screen the new changes are not shown, if I then press F5 to refresh the page the changes are then shown. I'm guessing this is some sort of caching issue? I've never had this problem with WebForms, I assum...

jQuery .slideUp() .slideToggle() in internet explorer produces the reverse effects of what was expected.

I am using the .slideUp() and .slideToggle to show and hide two divs based on the value selected in a radio button collection. It works fine in Firefox, Safari and Chrome, but internet explorer is producing the reverse effect than what I was expecting. Here is my Javascript function TogglePaypal() { $("#bank").slideUp(250,...

asp.net mvc selectlist - field to dictionary

Hi, I have a web service response of type AutomatOwners[] where AutomatOwners consists of two fields ID and Name. I would like to create a select list and then present it as dropdownlist, where Name would be displayed as an option and ID would be its option value. My idea was something like this: ViewData["automat_owners"] = new SelectL...

Handling Dates without years. From the DB all the way to the UI.

In the application I am currently writing the specification asks that a number of dates are entered without years. I want to know everyone opinion of the best way of doing this, at all levels. I am almost certain that they should be stored in the DB as normal Date fields, However before they get here, the year should always be set to th...

How to set one of the values in dropdownlist as selectedvalue in asp.net mvc?

I have a dropdownlist with values -1,1,2 and text A,B,C i wanna set B as selectedValue by default when the page is loaded. Something which can be done at the Page Level i.e in aspx or ascx. ...

Jquery.tabs: How do i use it with ASP.NET MVC

Hey Im trying to use Jquerys.tabs control. I dont see the logic. If i use PartialViews i migth as well wave goodbye to my Controller/Action logic, but then i would have to make ascx files, and i can't call those from my Controllers, or can i? Im not nessesarily interesseted in the ajax/unload onclick part, that Jquery.tabs() offers. I ...

[ASP.NET MVC] Passing Object Back to View in HttpPost

I'll make it simple, here's the code I've got. public ActionResult DeleteNonCIStaffUser(int id) { return View(_contractsControlRepository.FetchNonCIStaffUserByID(id)); } [HttpPost] public ActionResult DeleteNonCIStaffUser(ContractUser contractUser) { try { _contractsControlRepository.DeleteNonCIStaffUser(c...

ASP.NET MVC - Passing redundant arguments to actions

This question may seem a little bit stackoverflow-implementation specific, but I have seen a similar pattern on other websites that are using REST-friendly URL rewriting as well. For example, a link to a particular question looks like this: http://stackoverflow.com/questions/1388703/asp-net-mvc-passing-redundant-arguments-to-actions 13...

MVC ActionResult and QueryString

I'm a little puzzled with QueryStrings and ActionResult I have a URL coming in from jQuery as: url: "/ToBePaid/Receipt/" + $(this).attr('value') + "&receipt=" + $(this).attr('checked') which generates /ToBePaid/Receipt/28cb8260-d179-450f-b9c4-162f1cc45bbd&receipt=true and my ActionResult is as follows: public ActionResult ReceiptEx...

Looking for free asp.net mvc blog engine.

Oxite, AtomSite or someting other? I am searching simple integration with existing site (for example using own user and tag infrastructure) and extensibility (simple add new featuers). PS Can someone advice mvc forum little more complex than openforum? ...

Populating Html.DropDownList with foreign key table vlaues

Hello everybody! I am facing the problem that I cannot properly map my foreign key table values to an asp.net mvc edit view. I have placed a Html.DropDownList and made an IENumerable/IQueryable helper function returning: from item in db.items select item.name which populates my Html.DropDownList with all the Names in the foreign ke...