asp.net-mvc-2

Html.EditorFor() — editor template in portable area

*爱你&永不变心* 提交于 2019-12-24 09:55:07
问题 I am trying to use a partial view editor template in my application using the Html.EditorFor method in my view. If the editor template is directly in the Views/Shared/EditorTemplates directory of my application, it works great. If the editor template in the Views/Shared/EditorTemplates directory of the portable area I am using in my application (which is my intent in using this so I can use the same template in more than just this application), it is not being found. Is there a way I can make

How do I get the correct URL for an MVC action when using Jquery/AJAX?

对着背影说爱祢 提交于 2019-12-24 08:23:07
问题 So I have my first MVC2 site that I'm working on and naturally I'd like to throw some AJAX in there. The problem is, is that I don't know how to get the URL for the action when passing in a URL parameter. Let me explain. The examples I've seen so far show the developer passing in strings like '/MyController/MyAction'. That's great, except if your controllers are not in the root directory of your website (as is the case in my situation). I could always use relative URLs like 'MyAction' except

How to auto-generate simple CRUD controllers and views in ASP.Net MVC 2 (VS2010) Entity Framework project?

旧巷老猫 提交于 2019-12-24 07:39:53
问题 I have a standard template "ASP.NET MVC 2 Web application" solution, an empty (meaning no data inserted, but with all tables etc. ready and waiting) SQL Server database, an Entity Framework 4 model (edmx). Is there a way to generate simple CRUD controllers and form views for all the entities in the model? 回答1: A buddy out there helped me with the answer - the answer is to use a "ASP.NET Dynamic Data Entities Web Application" instead of "ASP.NET MVC 2 Web Application" project template. The

How to get the selected checkbox value in post action in mvc 2

别来无恙 提交于 2019-12-24 07:38:11
问题 I have got a checkbox list populated from database , I want to get the ID of each checkbox list during post action so that I can save that in the db , Below is the Code : Controller: public ActionResult Create() { ITrackdayRepository trackdayResp = new TrackdayRepository(); IQueryable<Object> getAllEvents = trackdayResp.GetEventsSelectlist(); var m = new SelectList(getAllEvents,"ID","Name"); ViewData["events"] = new SelectList(getAllEvents.ToList(), "EventID","Date"); return View(); } // //

mvc 2 start date and end date validation

跟風遠走 提交于 2019-12-24 06:45:00
问题 Hi guys i'm trying to compare two dates, for some reason the following code will return false, if i specify 25/05/2012 (startdate) and 31/05/12 (end date). This only happens if 25th is used as the start date, works fine if i use 26th. public bool IsValidDate(DateTime startDate, DateTime endDate) { return startDate < endDate && endDate > startDate; } what could be wrong? 回答1: You must be mistaken something. For the given input you specified this code returns true : class Program { static void

Login Security: How to Disable Multiple login

不羁的心 提交于 2019-12-24 05:59:18
问题 I want to disable multiple login on my web. For example when a user already login on the system. System should disable the user to login again on another browser or computer. Currently I tried doing this by using the database. I have a column like login_status, Once the user is login it will update to 1 and 0 for offline. If you the user closes the the browser without logging out. It will remain login, the user should ask the admin to log him out. The problem is we want to automatically

How to mass insert/update in linq to sql?

…衆ロ難τιáo~ 提交于 2019-12-24 05:42:47
问题 How can I do these 2 scenarios. Currently I am doing something like this public class Repository { private LinqtoSqlContext dbcontext = new LinqtoSqlContext(); public void Update() { // find record // update record // save record ( dbcontext.submitChanges() } public void Insert() { // make a database table object ( ie ProductTable t = new ProductTable() { productname ="something"} // insert record ( dbcontext.ProductTable.insertOnSubmit()) // dbcontext.submitChanges(); } } So now I am trying

ASP.NET MVC 2 and Google Maps Javascript API Version 3

限于喜欢 提交于 2019-12-24 05:17:10
问题 Somehow I cannot get a simple map to work in a ASP.NET MVC 2 application with Google Maps Javascript API V3. I have tried the following: Site.Master: Removed <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> Added <!DOCTYPE html> Added this in < head > <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript" src="http://maps.google.com/maps/api/js

Asp.net mvc form post and paging

谁都会走 提交于 2019-12-24 05:15:11
问题 I have an action method Search, which is called when a form is posted. There could be thousands of search resulst based on posted values of form. I want to show Search View page by page, but how can I know what form values was posted first time? so that I can call Search View by passing page parameters. 回答1: In my app all the action methods that provide data to grids take as a parameter an instance of this class: public class QuerySettings { private int page; public QuerySettings() : this

Why action not found in my controller?

為{幸葍}努か 提交于 2019-12-24 04:49:07
问题 I have this code: return RedirectToAction("Save", "RequestFinishedDocument", new {requestId = requestFinished.Request_ID, requestFinishedId = requestFinished.ID}); And in my controller I have: public class RequestFinishedDocumentController : Controller { [HttpPost] public JsonResult Save(int requestId, int requestFinishedId) { //todo } } But on the RedirectToAction call I get the exception message: A public action method 'Save' was not found on controller 'SuiP.Controllers