小编Noo*_*001的帖子

MVC 中的 Bootstrap 模式,双背景 - 背景出现两次

我在使用 jQuery 生成引导模式时注意到一个问题。在动态生成的部分视图(我的模式)中添加更多 JavaScript 会导致出现双背景。有谁知道为什么会发生这种情况?我正在使用 jquery-1.8.2.js 和 Bootstrap v3.1.1。非常感谢。

应用程序.js

$(document).ready(function () {

$('.modal-button').on('click', function (e) {
    // Remove existing modals.
    $('.modal').remove();
    $.ajax({
        url: '/Ajax/GetSearchModal/',
        type: "get",
        cache: false,
        success: function (data) {
            var modal = $(data);
            $(data).modal({
                backdrop: 'static',
                keyboard: false,
            });
        }
    });
});

});
Run Code Online (Sandbox Code Playgroud)

部分视图(我的模态)

@model MVCApp.Web.Models.ModalSearchModel
<div id="Ajax-Modal" class="modal fade" aria-hidden="true" role="dialog">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h3>
                    Select Something
                </h3>
            </div>
            @using (Html.BeginForm(Model.Action, Model.Controller, FormMethod.Post))
            { 
            <div class="modal-body">
                @Html.HiddenFor(m => m.SelectedDropDownID, new { @class …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc jquery modal-dialog twitter-bootstrap

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

为什么Xamarin形式的框架内的标签不可见?

我正在尝试为Xamarin表单中的标签创建简单的黑色边框。似乎框架内的任何内容都不可见。

这是我的代码:

<Frame BorderColor="Black"   
       CornerRadius="0">
    <Label x:Name="txtText"
           Text="Here"
               TextColor="Black"
               BackgroundColor="White"
               HorizontalOptions="FillAndExpand"
               VerticalOptions="FillAndExpand"
               HorizontalTextAlignment="Center" />
</Frame>
Run Code Online (Sandbox Code Playgroud)

我可以将框架中的background属性设置为任意值,并且可以正常运行,甚至尝试将其设置为透明都没有成功。

这就是我在上面的代码中看到的。

在此处输入图片说明

如果有帮助,我正在使用Visual Studio 2017和Android。

更新

我已经找到了解决方案,但是似乎很不客气。我已将其全部放入StackLayout中,将框架的请求高度设置为100,并将padding设置为1。

这是更新的代码:

<StackLayout>
    <Frame BorderColor="{DynamicResource PrimaryColour}"   
           CornerRadius="0"
           Padding="1"
           HeightRequest="100">
        <Label x:Name="txtText"
               Text="Here"
               TextColor="{DynamicResource PrimaryColour}"
               BackgroundColor="{DynamicResource SecondaryColour}"
               HorizontalTextAlignment="Center"
               VerticalTextAlignment="Center"/>
    </Frame>
</StackLayout>
Run Code Online (Sandbox Code Playgroud)

android visual-studio xamarin xamarin.forms

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

Ng-Bootstrap Datepicker,如何在 Angular4 中突出显示特定日期

我有一系列任务,每个任务都包含一个日期。我想突出显示日期选择器中的匹配日期,但似乎无法在文档中找到如何完成它。有人能帮忙吗?

https://ng-bootstrap.github.io/#/components/datepicker/api

这是我的打字稿:

import { Component, OnInit } from '@angular/core';
import {NgbDateStruct} from '@ng-bootstrap/ng-bootstrap';

const now = new Date();

@Component({
  selector: 'app-dashboard',
  templateUrl: './dashboard.component.html',
  styleUrls: ['./dashboard.component.scss']
})
export class DashboardComponent implements OnInit {

  constructor() { 
  }

  ngOnInit() {
  }

  model: NgbDateStruct;
  date: {year: number, month: number};

  selectToday() {
    this.model = {year: now.getFullYear(), month: now.getMonth() + 1, day: now.getDate()};
  } 
}
Run Code Online (Sandbox Code Playgroud)

和 HTML:

<ngb-datepicker #dp [(ngModel)]="model" (navigate)="date = $event.next"></ngb-datepicker>
Run Code Online (Sandbox Code Playgroud)

datepicker bootstrap-4 ng-bootstrap angular

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

如何在 IdentityServer4 中允许 Google 字体

要在 IdentityServer3 中使用 Google 字体,以下 Content-Security-Policy 从未奏效:

<meta http-equiv="Content-Security-Policy" 
      content=" style-src 'self' 'unsafe-inline' https://fonts.googleapis.com;
                font-src 'self' 'unsafe-inline' https://fonts.gstatic.com data:">
Run Code Online (Sandbox Code Playgroud)

相反,我们在 idsrvApp.UseIdentityServer 构造函数中配置了 CspOptions,它确实有效:

CspOptions = new CspOptions {
    FontSrc = "https://fonts.gstatic.com",
    StyleSrc = "https://fonts.googleapis.com",
    Enabled = true
}
Run Code Online (Sandbox Code Playgroud)

我们如何在 IdentityServer4 中配置 CspOptions?我很难找到它。

security identityserver4 google-fonts

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

C#偶尔的AccessViolationException

我有一个第三方库,有时会导致AccessViolationException.我已经标记了罪魁祸首.我真的很喜欢这种方法优雅地失败,这样我的调用代码可以在短时间内再次尝试,但此时,这个异常会导致整个应用程序崩溃.

    public static PlayerModel GetModel(int instanceId)
    {
        try
        {
            // New player model.
            PlayerModel model = new PlayerModel();

            // Fill.
            model._flakyLibrary = new FlakyLibrary(instanceId); // **Sometimes crashes**
            model.instanceId = instanceId;

            // Return the new player model.
            return model;
        }
        catch
        {
            // Try again in a bit - the game is not fully loaded.
            return null;
        }
    }
Run Code Online (Sandbox Code Playgroud)

我有一个想法是启动一个子进程来运行这一点逻辑并且如果需要那么优雅地崩溃 - 我不知道如何做到这一点,更不用说有一个进程返回这种对象(我的自定义PlayerModel )到另一个过程.我已经筋疲力尽地搜索谷歌和Stack Overflow(也许我在问错误的问题?).

非常感谢Theodoros.我已将以下属性添加到上述方法中.现在被抓住了例外.

[System.Runtime.ExceptionServices.HandleProcessCorruptedStateExceptions]
    [System.Security.SecurityCritical]
Run Code Online (Sandbox Code Playgroud)

PS - 如果有人知道我应该研究什么,我仍然着迷于了解多工艺解决方案?非常感谢再次.

另一个编辑:我找到了使用多个进程的解决方案:NamedPipeServerStream.

c#

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

Task.Run然后使用async await ContinueWith调用主线程替代?

以下代码完美无缺.它显示UI上的微调器,使用线程池中的线程启动任务并运行繁重的操作,一旦完成,隐藏微调器的逻辑就会按预期在主线程上执行.

    public void LoadCustomers()
    {
        // Update UI to show spinner
        this.LoadingCustomers = true;

        Task.Run(async () =>            
        {
            var customers = await this.custService.GetCustomers();
            // code truncated for clarity

            Device.BeginInvokeOnMainThread(() => 
            {
                // Update UI to hide spinner
                this.LoadingCustomers = false;
            });
        });
    }
Run Code Online (Sandbox Code Playgroud)

我的问题; 有没有更好的方法使用ContinueWith/ConfigureAwait选项编写此逻辑?使用这些选项似乎阻止了UI线程.在下面的示例中,UI线程是否应该继续运行UI逻辑(为微调器/用户输入设置动画),然后返回以完成ContinueWith内部的逻辑?

    public void LoadCustomers()
    {
        // Update UI to show spinner
        this.LoadingCustomers = true;

        this.custService.GetCustomers().ContinueWith((t) =>
        {
            var customers = t.Result;
            // code truncated for clarity

            // Update UI to hide spinner
            this.LoadingCustomers = false;
        }); …
Run Code Online (Sandbox Code Playgroud)

c# multithreading asynchronous xamarin.forms

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