asp.net-mvc-2

MVC 2 UpdateModel on Interface, Should ModelBinderAttribute be ignored?

冷暖自知 提交于 2019-12-09 01:49:01
问题 I have forms posting data from instances of a particular abstract class: public abstract class IRestriction { public string Name {get; set;} public abstract IModelBinder GetBinder(); } The concrete type and PartialView are determined at runtime: IRestriction restriction = (IRestriction)Activator.CreateInstance(Type.GetType(restriction.restriction_class)); The appropriate partial view is then rendered correctly. When the form is sent back the type is inferred correctly and activated the same

Outline text with System.Drawing?

那年仲夏 提交于 2019-12-08 23:45:28
问题 I have the following code. Is there an easy way to put an outline on the text I am writing? var imageEncoder = Encoder.Quality; var imageEncoderParameters = new EncoderParameters(1); imageEncoderParameters.Param[0] = new EncoderParameter(imageEncoder, 100L); var productImage = GetImageFromByteArray(myViewModel.ProductImage.DatabaseFile.FileContents); var graphics = Graphics.FromImage(productImage); var font = new Font("Segoe Script", 24); var brush = Brushes.Orange; var container = new

ASP.NET MVC 2 and lists as Hidden values?

霸气de小男生 提交于 2019-12-08 20:38:18
问题 Hi, I have a View class that contains a list, this list explains the available files that the user have uploaded (rendered with an html helper). To maintain this data on submit I have added the following to the view : <%: Html.HiddenFor(model => model.ModelView.Files)%> I was hoping that the mode.ModelView.Files list would be returned to the action on submit but it is not? Is it not possible to have a list as hiddenfield? More information : The user submit a couple of files that is saved on

MVC3 HTML helper doesn't update DropdownListFor on Submit the form

北城余情 提交于 2019-12-08 19:54:26
I have a simple HTML form with dropdwonListFor bound to colors, a textBox below it and submit button to submit the form and save the color. When I select a color from the dropdownlist, it will change the value of the textbox below it, if the user clicks the submit form. it goes back to the controller and I save the color from the texebox and return view(model) as an action result, but the problem that the dropdownlistfor doesn't get updated with the value of the textbox whether the value in the textbox within the dropdownlist or not. By the way you can test it urself Can anybody help please ?

ASP.NET web.config authorization settings ignored in subfolders

 ̄綄美尐妖づ 提交于 2019-12-08 19:25:33
问题 I'm using asp.net mvc 2 and vs 2008. I'm trying to make website with forms authorization. When i'm trying to restrict access to some pages, i'm using asp.net administration tool. There i create rule, for example, to deny access to anonimous users to whole web site. Administration tool, as expected, adds following section in the root web.config file: <authorization> <deny users="?" /> </authorization> When i do same thing in some subfolder, as example %ApplicationRoot%/View/Protected,

How can i get the MethodInfo of the controller action that will get called given a request?

孤街浪徒 提交于 2019-12-08 19:15:35
问题 I have a controller and action that's responsible for handling 403s due to the users not being in the correct roles. It has access to the original RequestContext that caused the exception. What I would like to be able to do is decorate my actions with a description of what they do, then allow the user to notify their manager, requesting access including the description in an email. So, how can I work out what action would be called given a RequestContext ? Obviously this is more complicated

asp.net mvc 2 to mvc 4

时光怂恿深爱的人放手 提交于 2019-12-08 18:21:43
问题 I would like to update my project from: ASP.NET MVC 2 with Entity Framework 4. to ASP.NET MVC 4 and Entity Framework 4.1 How can this be done? 回答1: You may take a look at the ASP.NET MVC 4.0 release notes which explain how to upgrade from an ASP.NET MVC 3 application. And the release notes of ASP.NET MVC 3.0 explain how to upgrade from ASP.NET MVC 2. As far as upgrading from EF 4.0 to EF 4.1, it's as simple as updating the assembly reference. Of course if you wanted to do Code First approach

Radio Button Change Event

倾然丶 夕夏残阳落幕 提交于 2019-12-08 17:24:52
问题 I am having 2 Radio Buttons.(For Ex : ID and Name).. <%=Html.RadioButton("Emp","1")%> <label>ID</label> <%=Html.RadioButton("Emp","2")%> <label>Name</label> If i click the Name, <p> <%:Html.LabelFor(m => m.MyDate)%>:  <%:Html.EditorFor(m => m.MyDate) %> </p> the above control should be visibled false..How to do this. 回答1: $(':radio[value=2]').click(function() { // Might need to adjust the selector here based // on the field you would like to hide $('#MyDate').hide(); }); or if you want to use

ASP.NET MVC2 CrAzY Characters in View Output - WTF

我与影子孤独终老i 提交于 2019-12-08 17:19:15
问题 Every once in a while when I'm running my app I get really "REALLY" strange characters in my output instead of the appropriate page. Now I know that this is because of some error, but unfortunately the error doesn't present it's self, but rather just produces strange characters. Here's an example of a complete page source code. �������� I�%&/m�{J�J��t�� $ؐ@�����iG#)� ��eVe]f@�흼��{���{��;�N'���?\fdl��J�ɞ!���?~|?"��Ey�')=��y6����h���u����r���j�fŲIU���<[��2O�2_����]i�ߴ��餚]����l�g���~��O��,[f

DropDownListFor(…) selecting boolean false by default

旧时模样 提交于 2019-12-08 16:42:46
问题 I have typical YesNo kind of dropdown in the application. For that, I have developed model (rather ViewModel Utility) class for future extension prupose. public string Text { get; set; } // represents text part public bool Value { get; set; } // represent value public List<DropDown> DropDowns { get; set; } //list for binding public void BuildYesNoDropDown() { DropDowns = new List<DropDown>(); DropDowns.Add(new DropDown { Text = "Yes", Value = true }); DropDowns.Add(new DropDown { Text = "No",