asp.net-mvc-2

LINQ to SQL - Grouping categories by parentId

大憨熊 提交于 2019-12-12 01:43:25
问题 I am trying to construct a navigation menu using a Categories table from my db. I have a similar layout as below in Categories table. public List<Category> CategoryData = new List(new Category[] { new Category{ CategoryId = 1, Name = "Fruit", ParentCategoryId = null}, new Category{ CategoryId = 2, Name = "Vegetables", ParentCategoryId = null}, new Category{ CategoryId = 3, Name = "Apples", ParentCategoryId = 1}, new Category{ CategoryId = 4, Name = "Bananas", ParentCategoryId = 1}, new

Can I use LabelFor() when the page inherits from IEnumerable<T>?

被刻印的时光 ゝ 提交于 2019-12-12 01:39:18
问题 Let's say, I've the following class definition: public class Person { [DisplayName("First Name")] public string FirstName { get; set; } [DisplayName("Last Name")] public string LastName { get; set; } } And, I'd like to use LabelFor(x =>x.FirstName) , and so on. Unfortunately, the page inherits from IEnumerable<T> so there's no way to use lambda expression. Is there any workarround? Or, I do have to use the Label(String) version? Thanks for helping 回答1: @Html.LabelFor(model => model

jquery $.ajax posts multiple times (one extra after each subsequent submit)

让人想犯罪 __ 提交于 2019-12-12 01:35:43
问题 On my forgot password form, the jquery ajax post is fired multiple times (one more after each submit). So if the user enters an invalid email 3 times, and then a valid email, the user gets 4 password-changed emails. Seems like the event gets stacked each time an error is thrown, and all of them get fired on the next submit. Here's all my relevant code. What am I doing wrong? JS RetrievePassword = function () { var $popup = $("#fancybox-outer"); var form = $popup.find("form"); form.submit

I can't pass a value to view

安稳与你 提交于 2019-12-12 01:35:32
问题 I am just playing with ASP.NET MVC 2 for learning. I can pass my models to view but after spend 1-2 hour i am unsuccessful to pass data to view.For example: www.example.com/home/show/asdf i am trying to get asdf string for show it on screen. public ActionResult Test(string ID) { return View(ID); } With this method i am trying to capture it.Then return view. In my view, i use <%: Html.LabelFor(m=>m as string) %> . This can be looking stupidly. I think that all strings on urls mapping to

Returning Redirect or PartialView from the same Action

大兔子大兔子 提交于 2019-12-12 01:33:31
问题 I have a problem with Ajax.BeginForm. I have a form with submit and button that updates partial view. What I am trying to accomplish is that I could use following return statements in the same Action. // button activates this return PartialView("PartialViewName", data); and // submit activates this return Redirect(model.Url); Now the problem is that Redirect causes problems to the Ajax.BeginForm <% using (Ajax.BeginForm("Action", "Controller", new AjaxOptions { OnSuccess = "OnSuccess",

MVC2.NET pass object from viewmodel to view and access it

♀尐吖头ヾ 提交于 2019-12-12 01:32:33
问题 When working with Viewmodels from linq to sql I have an architectural problem. When you have an object from your db (let's say "person"), and you load it in your viewmodel. After this in your view, when you try to acces referenced classes (let's say a person has children object which is a different table in db, and a different datacontext object). You get a "cannot access disposed datacontext object (or something) which is logical, because you loaded your object and disposed the datacontext.

Getting the Current controller and action sent to the Route

冷暖自知 提交于 2019-12-12 01:27:13
问题 I am attempting to Get the current controller and action being called in the route. In my Global.asax.cs I have the following using and the following line: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using System.Web.Routing; using IProwlAdminUI.Models; *** LINE WITH ISSUE*** string action = ViewContext.RouteData.Values["controller"].ToString() + ViewContext.RouteData.Values["action"].ToString() ******* Right now the ViewContext

When a submit button triggers a second form, the second form's submit button sends a POST request to the action of the original form

我与影子孤独终老i 提交于 2019-12-12 01:14:16
问题 I've been having trouble with MVC forms, specifically having a form submit and display a second form. The second form's submit button goes to the action of the original form. I asked if forms could be nested: Why do nested forms in Asp.net mvc not have scope?. Since form tags cannot indeed be nested, I changed things so the forms are in separate divs thinking that woudl resolve the problem. After the user clicks submit on the first form, the second form appears. When the user clicks on that

CacheInstaller.exe has stopped working

僤鯓⒐⒋嵵緔 提交于 2019-12-12 00:35:25
问题 I am having below mentioned issue when I am running Asp.Net MVC 2 project on windows Azure emulator (dev environment) I have installed Windows Azure SDK for .NET - October 2012 version and I am using cache feature on my system. With above error Below one is also comming. How to get rid of this ? 回答1: Maybe I have an stupid solution, but that works with me. When I begin to recieve the message "CacheInstaller.exe has stopped working", I do the following: 1) Stop the execution. 2) Go to the Role

get kmz file from controller

佐手、 提交于 2019-12-11 23:49:15
问题 I am trying to use some code taken here: to respond with a kmz file given a GET request. This is my code: public void GetKMZ() { this.Response.Clear(); Response.AddHeader("Content-Disposition", "attachment;filename=GoogleMap.kmz"); this.Response.ContentType = "application/vnd.google-earth.kmz"; this.Response.AppendHeader("Content-Encoding", "kmz"); byte[] bytes = null; MemoryStream memStream = new MemoryStream(); XmlTextWriter xmlTW = new XmlTextWriter(memStream,Encoding.UTF8); xmlTW