asp.net-mvc-2

POST Ajax call results in not found using jqGrid and ASP.NET MVC 2 on IIS6

萝らか妹 提交于 2019-11-28 11:34:30
问题 This is puzzling me. I deployed an MVC 2 application to IIS6 and everything works fine except for my jqGrid calls to get data. All is well on my development machine, but here are the two URLs I'm working with Local dev web server: POST http://localhost:port/Ctrl.mvc/JsonMethod IIS6 (notice https - not sure if that matters) POST https://www.domain.com/AppName/Ctrl.mvc/JsonMethod The latter URL results in a HTTP 404, which is really confusing as all works well on my local machine. The

File download in Asp.Net MVC 2

匆匆过客 提交于 2019-11-28 11:31:52
I want to enable file download in my MVC application, without simply using a hyperlink. I plan to use an image or the like and make it clickable by using jQuery. At the moment I have a simple just for testing. I found an explanation of doing the download through an action method, but unfortunately the example still had actionlinks. Now, I can call the download action method just fine, but nothing happens. I guess I have to do something with the return value, but I don't know what or how. Here's the action method: public ActionResult Download(string fileName) { string fullName = Path.Combine

asp.net-mvc2 - Strongly typed helpers not using Model?

风流意气都作罢 提交于 2019-11-28 10:50:22
问题 When using strongly typed helpers in MVC2 the input field values aren't taken from the Model property when a post is made. Is this default behavior? (strongly typed) view with strongly typed helpers: <div class="editor-label"> <%: Html.LabelFor(model => model.Name) %> </div> <div class="editor-field"> <%: Html.TextBoxFor(model => model.Name) %> <%: Html.ValidationMessageFor(model => model.Name) %> </div> <div class="editor-label"> <%: Html.LabelFor(model => model.Price) %> </div> <div class=

MVC - change model's value in view on post [closed]

青春壹個敷衍的年華 提交于 2019-11-28 10:46:20
I have view which displays some data from model. I have submit button which onClick event should change model's value and I pass model's with different values but my values in TextBoxFor stay the same as they were on page load. How can I change them? That's how HTML helpers work and it is by design. They will first look in the POSTed data and after that in the model. So for example if you have: <% using (Html.BeginForm()) { %> <%= Html.TextBoxFor(x => x.Name) %> <input type="submit" value="OK" /> <% } %> which you are posting to the following action: [HttpPost] public ActionResult Index

Can a Web User Control (.ascx) use a CSS file for styling?

∥☆過路亽.° 提交于 2019-11-28 10:08:49
问题 Here's the source of a blank .acsx file I created called LogOnBox. <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="LogOnBox.ascx.cs" Inherits="ECommerce.Views.Shared.LogOnBox" %> I want to drag some labels, and textboxes etc and give them style using a CSS file. How can I associate a CSS to an acsx file? 回答1: The CSS is associated to the page, and not the control specifically. But you can use the CSS in the control when the page has referenced it. 回答2: Just reference the css file

Why am I getting App_GlobalResources assembly generated? (Error = CS0433)

别来无恙 提交于 2019-11-28 10:00:49
问题 I'm working on a ASP.NET MVC2 project, for which I have configured the localisation as follows ... I have a separate Resources assembly, containing all my resx files. The settings for each resx file are... Build Action = Embedded Resource Copy to Output Directory = Do not copy Custom Tool = PublicResXFileCodeGenerator Custom Tool Namespace = Resources I have a tool which exports the strings from a database into the resx files and calls the resgen.exe tool to recreate the designer.cs file.

Stop the tag builder escaping single quotes ASP.NET MVC 2

∥☆過路亽.° 提交于 2019-11-28 09:48:07
I have the following HtmlHelper method that I want to create a button that does a redirect with JavaScript: public static string JavaScriptButton(this HtmlHelper helper, string value, string action, string controller, object routeValues = null, object htmlAttributes = null) { var a = (new UrlHelper(helper.ViewContext.RequestContext)) .Action(action, controller, routeValues); var builder = new TagBuilder("input"); builder.Attributes.Add("type", "submit"); builder.Attributes.Add("value", value); builder.Attributes.Add("class", "button"); builder.Attributes.Add("onclick", string.Format(

How can My Asp.Net C# class return a json format

爷,独闯天下 提交于 2019-11-28 09:47:54
How would like a class that will return a json format. This method work Great in the controller but when I want to put in a Class, the Json object don't seem to exist. public JsonResult Test() { //Error 1 The name 'Json' does not exist in the current context C:\inetpub\wwwroot\mvcinfosite\mvcinfosite\Validation\ValidationClass\BaseValidator.cs 66 20 mvcinfosite return Json(new { errMsg = "test" }); } I want to put that code in a simple class. I want be able to call this method in many controllers. Thanks. EDIT This is my Class (Where the code dosen't work) using System; using System

checkboxlist in asp.net MVC

此生再无相见时 提交于 2019-11-28 09:32:50
I want to create a checkboxlist in asp.net mvc view and want to display week days (monday tuesday, ....). I want to save the value(s) selected by user in database. How can I do this in MVC2 Someone suggested me to use "Enumeration Types as Bit Flags" mentioned here: http://msdn.microsoft.com/en-us/library/cc138362.aspx how can I use it ? Please suggest solution. Yes i would also suggest an enum in this scenario. Here is how you can do it in ASP.NET MVC: Your enum should look like this (see the link you provided): [Flags] public enum Days { Sunday = 0x1, Monday = 0x2, Tuesday = 0x4, Wednesday =

ASP.NET MVC 404 handling and IIS7 <httpErrors>

孤人 提交于 2019-11-28 09:23:09
Good day! I use strategy to handle 404 errors like this: Error handling for ASP.NET MVC 2 and IIS 7.0 or this: How can I properly handle 404 in ASP.NET MVC? In short: I handle 404 as exception in Global.asax without adding any routing rules, if the exception is 404 I render special controller\action with error message. On IIS6 it works with ASP.NET wildcard mapping. On IIS7 in integrated mode I need to add the following to the Web.config (where /error/HttpError404 is my action with 404 page): <httpErrors> <remove statusCode="403" subStatusCode="-1" /> <remove statusCode="404" subStatusCode="-1