asp.net-mvc-2

asp.net mvc htmlattribute without value

别来无恙 提交于 2019-12-23 07:47:05
问题 I am trying to create a hidden form according to the HTML5 spec, where the hidden attribute is used without a value. Now I have no idea how to force it into asp.net mvc's <% Html.BeginForm("ChangeContent", "Content", FormMethod.Post, new {hidden}); %> method as the one above does not compile with Compiler Error Message: CS0103: The name 'hidden' does not exist in the current context Any one knows a way out? EDIT Just out of curiosity using default html helpers? 回答1: I have a feeling that the

Asp.NET MVC ModelBinder, getting Action Method

丶灬走出姿态 提交于 2019-12-23 07:38:41
问题 I got a custom ModelBinder and i would like to get the action. Because i want to get the Attributes of the action using reflection, the action name is not enough. my action method: [MyAttribute] public ActionResult Index([ModelBinder(typeof(MyModelBinder))] MyModel model) { } and here a typically ModelBinder public class MyModelBinder : IModelBinder { public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { // here i would like to get the action

Wrapping an element with Html.ActionLink..?

百般思念 提交于 2019-12-23 07:03:22
问题 I'd like to wrap a span with an action link because I'm adhering to an existing CSS theme. It doesn't look like any of Html.ActionLink 's constructors allow for this. Possible solutions: A way to achieve this with existing helper? Derive & override ActionLink with new custom html helper? If #2 is the only way I have two questions. When I right click ActionLink and hit go to definition I only see the constructor signature not that actual code body. How do I see the original function body? I

difference between Html.TextBox and Html.TextBoxFor

白昼怎懂夜的黑 提交于 2019-12-23 07:02:35
问题 What is the difference between Html.TextBox and Html.TextBoxFor? As far as I know they produce same html output. Unless I'm missing something here. Please help me with this. 回答1: Html.TextBox is not strongly typed and it doesn't require a strongly typed view meaning that you can hardcode whatever name you want as first argument and provide it a value: <%= Html.TextBox("foo", "some value") %> You can set some value in the ViewData dictionary inside the controller action and the helper will use

how to create custom authorize filter in asp.net mvc3

会有一股神秘感。 提交于 2019-12-23 05:38:06
问题 i have a problem i am building a site in asp.net mvc3 , in which i made my several controllers all of them are authorized because i don't want that unauthorized user access that controller. Let suppose i have a controller and 2 methods in it as following using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; namespace Com.health.Controllers { [Authorize] public class MyfirstController : Controller { public ActionResult Index() { return View(

Add table dynamically in Entity framework in MVC

笑着哭i 提交于 2019-12-23 05:25:40
问题 I have an MVC application in which i need to add the table dynamically i.e table name is prepared dynamically. Is there any way we can check for the existence of a table and if not exist then add it in entity model. If we can are able to create the table then how we can access the dynamically created table name using the object of entity model? 回答1: No. If you want to use new table in EF you also need related entity (class), mapping and ObjectSet exposed in your context. Here you have some

Modify post data with a custom MVC extension?

落爺英雄遲暮 提交于 2019-12-23 05:03:58
问题 So I'm looking into writing some custom MVC extensions and the first one I'm attempting to tackle is a FormattedTextBox to handle things such as currency, dates, and times. I have the rendering of it working perfectly, formatting it, working with strong types and everything all golden. However, the problem I'm now running into is cleaning up the formatted stuff when the page posts the data back. Take for example, a currency format. Let's use USD for these examples. When an object has a

Modify post data with a custom MVC extension?

孤街醉人 提交于 2019-12-23 05:03:02
问题 So I'm looking into writing some custom MVC extensions and the first one I'm attempting to tackle is a FormattedTextBox to handle things such as currency, dates, and times. I have the rendering of it working perfectly, formatting it, working with strong types and everything all golden. However, the problem I'm now running into is cleaning up the formatted stuff when the page posts the data back. Take for example, a currency format. Let's use USD for these examples. When an object has a

ASP.NET MVC2 Parent Controller Not Redirecting

亡梦爱人 提交于 2019-12-23 04:48:20
问题 I have an ASP.NET MVC2 application that uses a parent controller to setup specific variables that are used around the app. I also implement validation to make sure that an ID in the URI exists in the database. If it does not, I redirect and stop the execution of the script. My parent controller looks something like this: // Inside class declaration // Set instance of account object to blank account protected Account account = new Account(); protected override void Initialize(System.Web

iframe good or bad for my MVC web-app scenario

落花浮王杯 提交于 2019-12-23 04:15:07
问题 I've been working into intranet web solutions which are to be used by a specific set of users of a system - like supply chain management. No SEO or marketing - only easy of use and simplicity that appeals them and makes their task simple. I'm using MVC2 with ASP.Net. I'll explain my scenario in generic terms. I've a page which has a tab view. The first tab loads a record from a master table and the other tabs load data for some details table. And ideal example would be like: Tab 1: Add/Edit