小编Irf*_*nif的帖子

如果数据绑定,则敲除字符串比较

category变量被定义为ko.observable()和子值应根据被改变category的值.
if if语句总是返回false.

<!-- ko if: $parent.category == "Electronics"-->
   <div>abc</div>
<!--/ko-->
Run Code Online (Sandbox Code Playgroud)

下面的if语句也总是返回false:

<span data-bind="if: $parent.category == 'Electronics'">
   <div>abc</div>
</span>
Run Code Online (Sandbox Code Playgroud)

如何在数据绑定中与硬代码值进行比较?

knockout.js

6
推荐指数
1
解决办法
1万
查看次数

html.routelink 不去指定路由

我有一堆路由定义为:

routes.MapRoute(
                name: "ID",
                url: "{category}/{subcategory}/{lowercategory}/{lowercategory1}/{id}/{ignore}",
                defaults: new { controller = "Home", action = "Index", ignore = UrlParameter.Optional }
            );

            routes.MapRoute(
                name: "LowerCategory1",
                url: "{category}/{subcategory}/{lowercategory}/{lowercategory1}",
                defaults: new { controller = "Home", action = "Index" }
            );

            routes.MapRoute(
                name: "LowerCategory",
                url: "{category}/{subcategory}/{lowercategory}",
                defaults: new { controller = "Home", action = "Index" }
            );

            routes.MapRoute(
                name: "Subcategory",
                url: "{category}/{subcategory}",
                defaults: new { controller = "Home", action = "Index" }
            );

            routes.MapRoute(
                name: "Category",
                url: "{category}",
                defaults: new { controller = "Home", action …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc routing asp.net-mvc-routing

5
推荐指数
1
解决办法
725
查看次数

Subdomain on localhost gives Bad Request - Invalid Hostname error

I am using MVC. I want to test subdomains on localhost with IIS. What I have done to create a subdomain is:

  1. I added a line to windows host file

    127.0.0.1       localhost
    127.0.0.1       abc.localhost
    ::1             localhost
    
    Run Code Online (Sandbox Code Playgroud)
  2. I edited applicationhost.config as:

     <bindings>
           <binding protocol="http" bindingInformation="*:59322:localhost" />
           <binding protocol="http" bindingInformation="*:59322:abc.localhost" />
     </bindings>
Run Code Online (Sandbox Code Playgroud)
  1. I added following class to RouteConfig.cs :

    public class SubdomainRoute : RouteBase { public override RouteData GetRouteData(HttpContextBase httpContext) { var host = httpContext.Request.Url.Host; var index = host.IndexOf("."); string[] segments = …

c# asp.net subdomain asp.net-mvc asp.net-mvc-routing

5
推荐指数
1
解决办法
1363
查看次数

XmlNodeConverter 只能转换以对象开头的 JSON

我的webapi方法是:

public JsonResult<List<MyClass>> PullData()
{
    List<MyClass> data = new List<MyClass>();
    data = db.TableName.Select(x => new MyClass
    {
        Id = x.Id,
        IsActive = x.IsActive,
        //other attribute..
    }).ToList();

    return Json(data);
}
Run Code Online (Sandbox Code Playgroud)

我将此 webapi 用作:

public async Task<string> Index()
{
    string apiUrl = "http://localhost:90/api/Scheduler/pulldata";

    using (HttpClient client = new HttpClient())
    {
        client.BaseAddress = new Uri(apiUrl);
        client.DefaultRequestHeaders.Accept.Clear();
        client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));

        HttpResponseMessage response = await client.GetAsync(apiUrl);
        if (response.IsSuccessStatusCode)
        {
            var data = await response.Content.ReadAsStringAsync();

            JsonConvert.DeserializeXmlNode(data, "root"); //exception: XmlNodeConverter can only convert JSON that begins with an …
Run Code Online (Sandbox Code Playgroud)

c# xml asp.net-mvc json asp.net-web-api

5
推荐指数
1
解决办法
1万
查看次数

如果参数为空,则查询返回所有记录

我的数据库表是:

----------
|   Ad   |
----------
|Id
|title
|price
|tags
|brand
|model
Run Code Online (Sandbox Code Playgroud)

我必须Ad按 6 个参数进行搜索,即按品牌、型号、标签、标题、minPrice 和 maxPrice。现在,如果为 null,则它应该选择所有行,否则仅选择那些等于 的brand行。branduserDesiredBrand

我的职能是:

public async Task<IHttpActionResult> SearchAds(string brand, string model,string tags,string title, int minPrice, int maxPrice){
     if(brand != null && model != null && tags != null && title != null && minPrice != null && maxPrice != null){
           var ret = from ad in db.Ads
                     where ad.brand.Equals(brand) && ad.model.Equals(model) && ad.tags.Equals(tags) && ad.title.Equals(title) && ad.price > …
Run Code Online (Sandbox Code Playgroud)

c# sql-server asp.net-mvc ado.net

2
推荐指数
1
解决办法
5216
查看次数

单击列时,角度表可防止行单击

当我单击表行时,它应该展开并显示一些额外的数据,但是当我单击列时,它不应该展开行,而不应该执行列单击。

我已经简化了代码,请在此处查看完整的代码示例

    <!-- Weight Column -->
    <ng-container matColumnDef="weight">
        <th mat-header-cell *matHeaderCellDef> Weight </th>
        <td mat-cell *matCellDef="let element" (click)="weightCicked(element)"> {{element.weight}} </td>
      </ng-container>
    
      <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
      <tr mat-row (click)="rowclicked(row)" *matRowDef="let row; columns: displayedColumns;"></tr>
Run Code Online (Sandbox Code Playgroud)

当我点击weight列时,rowClicked也被调用,我怎样才能调用唯一的weightCicked方法

angular-material angular

1
推荐指数
1
解决办法
2841
查看次数