asp.net-mvc

Why do session variables not work properly when following a link from an MS Word document

If you have a link to a webpage in a MicroSoft Word document and you follow this link to get to the web page ASP.Net session variables do not always work as expected. In particular they work the first few times and then later on they stop working. For instance if you have a link to an MVC Page like: http://localhost/Home/TransferToWeb...

ASP.NET MVC: Controlling serialization with JsonResult

Is there a way to control the JSON output of JsonResult with attributes, similar to how you can use XmlElementAttribute and its bretheren to control the output of XML serialization? For example, given the following class: public class Foo { [SomeJsonSerializationAttribute("bar")] public String Bar { get; set; } [SomeJsonSe...

How to name Asp.net Mvc controllers?

Hi I am kinda of confused on when I should be making a new controller it seems like every time I make a button that goes somewhere I would need to make a new controller to get the right pathing names. For instance in this scenario I have a signIn controller. this controller would have 1. Login view 2. RestPassword view 3. CreateAcc...

ASP.NET MVC - Disable Html Helper control using boolean value from Model

I am outputting a textbox to the page using the Html helpers. I want to add the disabled attribute dynamically based on whether or not a boolean value in my model is true or false. My model has a method that returns a boolean value: <% =Model.IsMyTextboxEnabled() %> I currently render the textbox like follows, but I want to now enabl...

How to generate urls on the client side using ASP.NET MVC ?

One of the great things about ASP.NET MVC is the routing engine. I love to generate my urls and not having anything break when I change the routes. However, I'm not sure how I can apply this mechanism on the client side. Let's imagine a common scenario where I have two dropdown lists and the content of the second list depends on the se...

Check the date with Linq-to-SQL

I have the following problem: in a database table are Sales recorded. One of the field is the SaleDate which is a SQL Server Date type. The Website now allows to search in this field. And it allows to search only for the year. Let's assume there is one record with the date 2008/11/01. If I search for "2008" the entry is returned, which ...

ASP.NET MVC Deployment Issues...

HI am new to ASP.NET MVC and I am running into some issues trying to deploy a very simple site! I took the MVC Storefront (Kona), made some basic changes and now I would like to deploy it to a webserver! For testing, I just turned on IIS7 on my windows 7 desktop! I change the web projects settings to use local IIS and run it! The first ...

Better code: Extend LINQ class, or create separate helper class?

Hello, I'm trying to figure out what the better/cleaner/more maintainable way is, for the following problem. My "Customer" class is generated via LINQ from the database. The customer has a special activation link which is a URL that needs to be generated from data from both a Customer instance and some static configuration data. Solutio...

ASP.NET MVC Roles without database (and without role provider)

I have a super simple ASP.NET MVC application that uses RpxNow (OpenID) to allow users to login. I now want to let users edit their own account and provide administrator access to edit anyone's account. I have two separate "Edit Account" views: ~/account/edit/ ~/account/edit/1 The first loads the account details based on the logged ...

MVC DropDownList SelectedItem Value in ActionLink

Hi, I'm a bit confused and sorry if this question is repeated elsewhere, I did check and it didnt seem to be here yet. Is there a way, (without use of JavaScript) to get the currently selected item of a DropDownList and say send it off to an ActionLink? <%= Html.DropDownList("Elements") %> <%=Html.ActionLink("Add Authorization Ele...

ASP.NET MVC: Criteria for controller's method to be an action?

I'm writing some unit tests to assert that all our controller action methods are marked with proper custom attributes, but I don't really know what the criteria is for determining whether a public method can act as MVC action or not. I would assume that a criteria could be the return value type (it has to be ActionResult or a derivativ...

Advice On Managing Models [ASP.NET MVC]

Seeing as though ASP.NET MVC 2 Preview 1 was just released it means the way things are done may be slightly different in terms of the model. The DataAnnotation feature allowing validation to be done against properties in its model is good, but I'm not sure where to put it. I create my models manually as recommended in Steve Sanderson's...

castle windsor doesn't inject dependency into properties

i have asp.net mvc application i have created a custom membership provider he is bound in web.config like this: <membership defaultProvider="MyMembershipProvider"> <providers> <clear/> <add name="MyMembershipProvider" type="MyProject.Infrastructure.Security.MyMembershipProvider" /> </providers> </membersh...

Asp.Net MVC - Creating a treeview based on the node clicked

I know how to render a unordered list with children when returning data from the database but I have a slightly different requirement. My view has a top level of list items in the UL made up of dates. When the user clicks a date it needs to send that server side to run a query to render the possible children. It has to do this up to 4...

How to post ASP.NET MVC Ajax form using JavaScript rather than submit button

I have a simple form created using Ajax.BeginForm: <% using (Ajax.BeginForm("Update", "Description", new { id = Model.Id }, new AjaxOptions { UpdateTargetId = "DescriptionDiv", HttpMethod = "post" },new {id ='AjaxForm' })) {%> Description: <%= Html.TextBox("Description", Model.Description) %><br /> <input ty...

Using of Object Reference in Entity Framework

I want to create new object with the FK reference on the entity in onother table. It's just a simple create view but i don't know how to reference the Research entity with ID == id. public ActionResult Create(int id) { SurveyPaper surveyPaper = new SurveyPaper(); return View(surveyPaper); } [AcceptVerb...

asp.net mvc: is this request routed or not?

Hello everyone, in order to estimate the execution time of the requests sent to my mvc applications, i've been using log4net to log the time elapsed in the EndRequest event of global.asax for my MVC application. However, the EndRequest is called for every request, including the resources (css, images); i'd prefer to be able and distingu...

ASP.NET MVC wrong url in ajax calls

Hi. I have wrong URL in my ajax calls. $.ajax({ type: "POST", url: "Home/GetDetails", ...... }); HomeController has action GetDetails(). All works fine, when I load page with URL htp://localhost/projectName Ajax URL is htp://localhost/projectName/Home/GetDetails But after loading htp://localhost/projectName/Home/Index ...

How to add data attributes to html element in ASP.NET MVC?

I learned few minutes ago that adding data attributes is a nice way to add custom information to html elements. So I tried to do like this: <%= Html.TextBox ("textBox", "Value", new { data-myid = m.ID })%> But it ends up as a syntax error. How can I define custom data attributes? EDIT: I see that I can achieve this effect using: <%...

C# (.NET) handling Javascript Array/Serialization

I'm using tableDnD to re-order table rows, and then serialize them using "$.tableDnD.serialize()" I want to send this to C# for processing, what's the best of doing so? The below is an example of the serialization pages[]=&pages[]=21&pages[]=23&pages[]=34&pages[]=37&pages[]=40&pages[]=43&pages[]=46&pages[]=49&pages[]=31&pages[]=50&pag...