asp.net-mvc-2

NewLine in Constant in Aspx Page

最后都变了- 提交于 2019-12-11 07:29:17
问题 <table cellpadding="0" cellspacing="0" width="100%"> <% if(ViewData["CustomerInfoList"] !=null && ((List<SaaSModel.CustomerInfo>)ViewData["CustomerInfoList"]).Count()>0) { %> <tr> <td> <% Html.Grid((List<SaaSModel.CustomerInfo>)ViewData["CustomerInfoList"]).Columns( column=> { column.For(col=>col.CustomerName).Named("Name"); column.For(col=>col.CompanyName).Named("CompanyName"); column.For(col=>col.Description).Named("Description"); column.For(col=>col.CustomerRevenue).Named("CustomerRevenue"

LIstbox in MVC 2

徘徊边缘 提交于 2019-12-11 07:21:16
问题 I am having a Employee Table. From that i want to load the Employee Names in a List Box. I dont know from where i should start. Kindly guide me. 回答1: As always start by defining the view model that will represent your data: public class Employee { public string Id { get; set; } public string Name { get; set; } } public class MyViewModel { public string SelectedEmployeeId { get; set; } public IEnumerable<Employee> Employees { get; set; } } Then the controller which will manipulate the model:

Cascading dropdown

。_饼干妹妹 提交于 2019-12-11 07:14:36
问题 Is there any alternative to json data to cascade dropdowns? I am using country and state dropdown but cascading the data with json take too much time [HttpGet] public ActionResult States(int countryId) { DateTangoEntities _db = new DateTangoEntities(); var tset = _db.States.Where(r => r.CountryID == countryId).Select(r => new { r.StateName, r.StateID }); return Json(tset, JsonRequestBehavior.AllowGet); } and here is the jquery part $(document).ready(function () { var countries = $("#Country")

Changing Synchronous operations into Asynchronous in Business Service & Repository Layers (ASP.NET MVC 2)

寵の児 提交于 2019-12-11 07:02:29
问题 I am working on a Travel related website and here is my high level architecture: ASP.NET MVC 2 (Presentation Layer) Services Layer Repository Layer communicating with external J2EE Services Currently all of my layers support ONLY Synchronous communication like this: //Pricing Controller... public ActionResult GetRates() { //Contruct Pricing Request //PricingRequest request = Contruct Pricing Request...; PricingResponse response = _pricingService.GetComponentPricing(request); //.... //...

Create RouteValueDictionary on server and use in aspx?

别说谁变了你拦得住时间么 提交于 2019-12-11 06:59:18
问题 I am tring to pass a RouteValueDictionary to my aspx so that I can use it as the parameters for an Ajax.BeginForm method. I load it up like so: RouteValues = new System.Web.Routing.RouteValueDictionary(); RouteValues.Add("FindingId", thisFinding.Id); RouteValues.Add("ReportId", thisFinding.ReportSection.ReportId); and then add it to my model without issue. When I put it as the parameter to the BeginForm method it renders the action as this: /SolidWaste/Finding/LoadSection?Count=3&Keys=System

ASP.NET GetFullHtmlFieldId not returning valid id

梦想与她 提交于 2019-12-11 06:55:28
问题 In MVC2 template, I normally use this.ViewData.TemplateInfo.GetFullHtmlFieldId(fieldName) to generate the id field of an html element. This has worked in most of the cases. However this method does not actually return valid id field, it merely prefix fieldName with ViewData.TemplateInfo.HtmlFieldPrefix , this is causing problems for me when rendering collections which has [] in the HtmlFieldPrefix. I have been manually converting those characters to _ where I find the need, but this seems to

.NET SQL new table doesn't exist

只谈情不闲聊 提交于 2019-12-11 06:53:51
问题 NOTE: This issue has been resolved, but lead to a new question. I'm getting this error: System.Data.SqlClient.SqlException "Invalid object name [tablename]" I'm working on a DB update to ship with an update to a deployed product. The first time the newly updated application runs, the database update runs, and it has two primary stages. Run script update.sql to add new tables to the database Call some methods to copy some data from existing tables to popuplate the new tables, and do some math

Can i browse file stored on Remote server through simple <input type=“file”> control in asp.net MVC 2.0

六眼飞鱼酱① 提交于 2019-12-11 06:49:42
问题 I have a file control of HTML <input type="file"> And i want to browse file from the remote server. I want to locate a file which is stored on remote server . For eg. If my website is hosted on http://192.168.56.116 and if there is a folder on server http://192.168.56.116/UploadedFiles then i should be able to browse files contained in that folder. Is this thing is possible in asp.net MVC 2.0 ??? Please suggest me any alternative or solution for this problem. Thanks, Manoj 回答1: There is no

Custom HTML Helpers in ASP.NET MVC 2

青春壹個敷衍的年華 提交于 2019-12-11 06:49:30
问题 I want to create a pagination helper. The only parameters that it needs are currentpage, pagecount and routename. However, I do not know if it is possible to use the return value of another html helper inside the definition of my html helper. I am referring specifically to Html.RouteLink. How can I go about doing something like this in the class definition using System; using System.Web.Mvc; namespace MvcApplication1.Helpers { public static class LabelExtensions { public static string Label

Why does updating an object only work one, particular way?

谁说胖子不能爱 提交于 2019-12-11 06:38:39
问题 I am trying to update an object using EF4. An object is passed from the strongly-typed page to the action method and [HttpPost] public ActionResult Index(Scenario scenario, Person person) { // Some business logic. // Update Scenario with Person information. scenario.Person = person; // Update the corresponding object and persist the changes. // Note that the repository stems from the repository pattern. Contains the ObjectContext. Scenario updateScenario = repository.GetScenario(scenario