我有以下情况.
我开发了我的第一个MVC Asp.Net应用程序.它在我的服务器上运行以下地址
http://localhost:59441/
Run Code Online (Sandbox Code Playgroud)
我写了一些看起来像这样的JQuery Post Methods
$.ajax({
type: "POST",
url: "/CeduleGlobale/UpdateCheckBox", ...
Run Code Online (Sandbox Code Playgroud)
CeduleGlobale是我的ControllerName,UpdateCheckBox是我的methodName
当我将应用程序放在testServer上时,它被放在VirtualDirectory中
因此现在申请
http://testServer/JprApplication/
Run Code Online (Sandbox Code Playgroud)
没有更多要指定的端口以及应用程序名称
当我开始测试时,我很快发现我的JQuery Post调用不再起作用了......
我修改了它们,所以现在URL是
/JprMvc/CeduleGlobale/UpdateCheckBox
Run Code Online (Sandbox Code Playgroud)
问题是2倍.
我确信我遗漏了一些基本的东西来简化这个.
谢谢
我想弄清楚如何简化以下内容
假设我有2个实体类
public class A
{
public int Id { get; set; }
public string Name { get; set; }
public string City { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
和
public class B
{
public int Id { get; set; }
public string Nom { get; set; }
public string Ville { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
类似但不相同的类.
每个类都有一个用于CRUD操作的存储库类,例如......
public class RepA
{
public static List<A> GetAll()
{
List<A> list = new List<A>();
A a1 = new A() {Id=1, Name="First A", City="Boston"}; …Run Code Online (Sandbox Code Playgroud) 我在视图中使用DevExpress.ComboBoxFor.
@using (Ajax.BeginForm(actionName: "DetailPartialAction", controllerName: "CeduleDepartementale", ajaxOptions: new AjaxOptions { HttpMethod = "POST", InsertionMode = InsertionMode.Replace, UpdateTargetId = "target" }))
{
@Html.DevExpress().LabelFor(x => x.CeduleDateFrom)
@Html.EditorFor(x => x.CeduleDateFrom)
@Html.LabelFor(x => x.CeduleDateTo)
@Html.EditorFor(x => x.CeduleDateTo)
@Html.LabelFor(x => x.WorkCenter)
@Html.DevExpress().ComboBoxFor(x => x.WorkCenter,
settings =>
{
settings.Name = "WorkCenter";
settings.Width = 180;
settings.SelectedIndex = 0;
settings.Properties.TextField = "Name";
settings.Properties.ValueField = "No";
settings.Properties.ValueType = typeof (string);
}).BindList(CeduleProduction.Repository.Concrete.WorkCenterRepository
.GetAll()).GetHtml()
<input type="submit" value="OK"/>}
Run Code Online (Sandbox Code Playgroud)
当我提交表单时,不使用valuefield,它是textfield,我需要更改以允许传递值(未显示)而不是显示的textfield
我有这个界面:
public interface IEntity
{
int Id{get;set;}
}
Run Code Online (Sandbox Code Playgroud)
一类:
public class Customer: IEntity
{
public int Id { get; set; }
public string Name { get; set; }
public int Age { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
这是我的用法:
void Main()
{
List<Customer> list = new List<Customer>();
IEntity obj = null;
obj = new Customer() {Id = 4, Name="Jenny", Age =41};
list.Add(obj as Customer); /*Line #1*/
list.Add((Customer)obj); /*Line #2*/
}
Run Code Online (Sandbox Code Playgroud)
这被认为是最佳做法:第1行或第2行?
我有以下XML
<?xml version="1.0"?>
<NavResponse>
<Response>
<Products>
<Product>
<field name="Id" value="BST-U3009W"/>
<field name="Point" value="1"/>
</Product>
<Product>
<field name="Id" value="BST-U5047W"/>
<field name="Point" value="1"/>
</Product>
<Product>
<field name="Id" value="BST-U7023W"/>
<field name="Point" value="1"/>
</Product>
<Product>
<field name="Id" value="BST-U9007"/>
<field name="Point" value="1"/>
</Product>
<Product>
<field name="Id" value="BTS-U8010"/>
<field name="Point" value="1"/>
</Product>
</Products>
</Response>
<Id>00000000-0000-0000-0000-000000000000</Id>
<Errors/>
</NavResponse>
Run Code Online (Sandbox Code Playgroud)
我想把它变成一个产品清单
产品在哪里
public class Product
{
public string Id {get;set;}
public int Point {get;set;}
}
Run Code Online (Sandbox Code Playgroud)
我尝试过这样使用Linq
XDocument fooXML = XDocument.Load(@"c:\fred\foo.xml");
Run Code Online (Sandbox Code Playgroud)
然后这个
var pairs = XDocument.Parse(fooXML.ToString())
.Descendants("field")
.Select (xd => …Run Code Online (Sandbox Code Playgroud) c# ×4
asp.net-mvc ×2
.net ×1
devexpress ×1
generics ×1
interface ×1
jquery ×1
list ×1
parsing ×1
url-routing ×1
xml ×1