asp.net-mvc-2

Issue while store the javascript textbox value into DB using ajax code in MVC2

若如初见. 提交于 2019-12-11 23:28:08
问题 I may be missing something obvious here, but how could I rewrite this code! i am trying here to store the value entered in the textbox(Textbox was showed in javascript dialog page).In a javascript dialog page i have one 'ok' button.. when i click the button i want to store the value entered in the textbox.I want to save the content using Ajax. Please see my sample code View page: <script language="javascript" type="text/javascript"> $(function () { $('.button').live('click', function () { $('

setting displayname data annotation dynamically in asp.net mvc

心不动则不痛 提交于 2019-12-11 23:17:32
问题 I have a database table with the following fields item_key, item_value, display_name, uihint I want to be able to specify in the database table which displaytemplate to use and also the displayname. <%= Html.EditorFor(p=>pageField.item_value, pageField.uihint) %> The UIHint is working, but I can't work out a way of setting the displayname dynamically, the above code is producing something like item_value TEXTBOX item_value TEXTBOX item_value TEXTBOX Where I want the item_values titles to be

Custom Excel Export Action

 ̄綄美尐妖づ 提交于 2019-12-11 22:53:45
问题 public class ExcelResult<Model> : ActionResult { string _fileName; string _viewPath; Model _model; ControllerContext _context; public ExcelResult(ControllerContext context, string viewPath, string fileName, Model model) { this._context = context; this._fileName = fileName; this._viewPath = viewPath; this._model = model; } protected string RenderViewToString() { using (var writer = new StringWriter()) { var view = new WebFormView(_viewPath); var vdd = new ViewDataDictionary<Model>(_model); var

Validating multiple textboxes using JqueryValidation in MVC

牧云@^-^@ 提交于 2019-12-11 22:05:52
问题 Iam rendering partial a view twice on the same parent view.Since each child view has 1 textbox each I have 2 textboxes. Iam trying to use JqueryValidation Plugin as in $("#form0").validate({ rules: { Address<%=Model.TypeName%>: { required: true, minLength: 8 } }, messages: { Address<%=Model.TypeName%>: : { required: "Please enter an address", minLength: "Your address must consist of at least 8 characters" } } I have two Model.TypeNames , 1) student, 2) parent. When I try to validate both the

OnClick event on button in MvcContrib Grid column not working

爱⌒轻易说出口 提交于 2019-12-11 20:46:22
问题 I am new to mvc.I am using MvcContrib Html.Grid in my MVC 2 project.I have an existing Html.Grid where I have to added a new column with a button in it. The button will be enabled/disabled bsed on the "status" column in the grid. I managed to get the button in the column and enable/disable it based on the "status" column. Here's the code: column.For(c => c.Status == "Complete" ? "<input type=\"button\" value=\"PDF\" onClick=\"\" >" : "<input type=\"button\" value=\"PDF\" onClick=\"\" disabled

Why isnt my EditorTemplate binding a List on [HttpPost], but renders it fine on [HttpGet]?

笑着哭i 提交于 2019-12-11 19:18:04
问题 I have uploaded my code to pastebin, this is the link: http://pastebin.com/wBu9PP2x When i submit a form, the Lists that i use are not bound to my ViewModel. But when i send the ViewModel to the view, it renders fine using EditorFor. I have read that when using EditorTemplates, it is supposed to name the List appropriately so that they are bound to the ViewModel automatically upon postback. The HTML output can be seen here: http://pastebin.com/5KeyNXWC Notice that the ViewModel derives from

ASP.NET MVC 2 - Property validation

谁说我不能喝 提交于 2019-12-11 18:58:01
问题 I'm new to MVC and have a question regarding validation. Is there a way to dynamically set the Error Message? For example, how could I achieve the following (ignore the hardcoded 50, this could come from the Web.config or specific to the current logged). [MetadataType(typeof(DocumentValidation))] public partial class Document { public class DocumentValidation { private const int MaxLength = 50; [Required(ErrorMessage = "Document Title is required")] [StringLength(MaxLength, ErrorMessage =

Log user in manually with Forms Authentication

廉价感情. 提交于 2019-12-11 18:47:44
问题 I'm trying to implement token-based authorization for an Asp.Net MVC2 app, and I think my approach is wrong. First off: by token-based authorization I mean that when an unauthenticated user goes to http://myapp.com/some/action?tok=[special single-use token here] they are logged in. All of the controllers in my app extend a common ApplicationController , so my approach was to override OnAuthorize on that controller as follows: class ApplicationController { protected override void

Compiler error using EF4 as a separate project than my MVC project

假如想象 提交于 2019-12-11 18:30:03
问题 I'm trying to follow the general consensus that it's best to put one's domain objects in a separate project than their MVC project, but am getting the following compiler error: The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid. Source File: C:\Users\Kevin\documents\visual studio 2010\Projects\HandiGamer\HandiGamer.Domain\Entities\HGDomainModel.Designer.cs Line: 44 Line 42: /// Initializes a new

Store user data in MVC 2

穿精又带淫゛_ 提交于 2019-12-11 16:56:58
问题 So when a user comes to my page, there is certain data that I want to store from how they are interacting with the page. None of this data is being persisted though, so I'm trying to figure out the best way to do it. For example, they log onto my page, and I'm getting their location through javascript/google maps. Should I store that in the session? I'm also getting their IP through javascript. Should I just make the javascript query everytime I need to use it or should I store that in the