小编Han*_*ing的帖子

刷新 Blazor 页面

使用 .NET 6 的 Blazer 服务器端项目中,我位于以下页面:

\n

https://localhost:7252/Product/a3620f82-7cba-473c-9273-1cf300a181eb

\n

我在此页面上有一个导航链接,它指向上面完全相同的 URL。但是当我点击该方法时,页面没有任何反应,也没有刷新或更新。我应该怎么办?

\n

我的代码示例:

\n
@page "/Product/{Id:guid}"\n@using Application.ProductGalleries.Queries\n@using Application.Products.Queries\n@using ViewModels.ProductVariants\n@using ViewModels.ProductVariantsDetails\n@using ViewModels.Products\n<div class="col-12 px-0">\n                        <h1>\n                            <NavLink href="@($"/Product/a3620f82-7cba-473c-9273-1cf300a181eb")">@Model.ProductName</NavLink>\n                            </h1>\n                        <p>\xd8\xaf\xd8\xb3\xd8\xaa\xd9\x87 \xd8\xa8\xd9\x86\xd8\xaf\xdb\x8c : @Model.CategoryName<span> \xd8\xa8\xd8\xb1\xd9\x86\xd8\xaf: @Model.BrandName</span></p>\n                        <nav aria-label="breadcrumb">\n                            <ol class="breadcrumb">\n                                <li class="breadcrumb-item"><NavLink href="/">\xd8\xb5\xd9\x81\xd8\xad\xd9\x87 \xd9\x86\xd8\xae\xd8\xb3\xd8\xaa</NavLink></li>\n                                <li class="breadcrumb-item"><NavLink href="/Products">@Model.CategoryName</NavLink></li>\n                                <li class="breadcrumb-item active" aria-current="page">@Model.BrandName</li>\n                            </ol>\n                        </nav>\n                    </div>\n\n\n@code {\n[Parameter]\npublic Guid Id { get; set; }\nprotected override Task OnParametersSetAsync()\n{\n    return base.OnParametersSetAsync();\n}\nprotected override Task OnAfterRenderAsync(bool firstRender)\n{\n    return base.OnAfterRenderAsync(firstRender);\n}\n\nprotected override bool ShouldRender()\n{\n    return base.ShouldRender();\n}\nprotected override void …
Run Code Online (Sandbox Code Playgroud)

c# blazor blazor-server-side

20
推荐指数
3
解决办法
3万
查看次数

处置或不处理(CA2000)

我正在开启旧项目的代码分析.大多数评论结果我都能理解,但 CA2000:在丢失范围之前处理对象很难做到.

例如,来自ASP.Net页面的此代码:

private void BuildTable()
{
    HtmlTableRow tr = new HtmlTableRow();
    HtmlTableCell td = new HtmlTableCell();

    tr.Cells.Add(td);
    // add some controls to 'td'

    theTable.Rows.Insert(0, tr);
    // 'theTable' is an HtmlTable control on the page
}
Run Code Online (Sandbox Code Playgroud)

提供CA消息:

CA2000:Microsoft.Reliability:在方法'BuildTable()'中,在对所有引用超出范围之前,在对象'tr'上调用System.IDisposable.Dispose.

CA2000:Microsoft.Reliability:在方法'BuildTable()'中,对象'td'未沿所有异常路径放置.在对对象'td'的所有引用都超出范围之前调用System.IDisposable.Dispose.(以及关于添加到'td'的控件的类似消息.)

我可以解决第二个问题:

private void BuildTable()
{
    HtmlTableRow tr = new HtmlTableRow();
    HtmlTableCell td = new HtmlTableCell();

    try
    {
        tr.Cells.Add(td);
        // add some controls to 'td'

        td = null; // this line is only reached when there were no exceptions
    }
    finally …
Run Code Online (Sandbox Code Playgroud)

.net dispose code-analysis

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

E_UNEXPECTED UWP灾难性失败

我得到以下内容:

灾难性故障(HRESULT异常:0x8000FFFF(E_UNEXPECTED))

当ListView属性在Visual State中设置为Null时.这没有任何意义,为什么VS和Blend会抱怨?

<VisualState.Setters>
     <Setter Target="listView.(Selector.IsSynchronizedWithCurrentItem)" Value="{x:Null}"/>
</VisualState.Setters>
Run Code Online (Sandbox Code Playgroud)

编辑
一个类似的问题:

 <VisualState.Setters>
   <Setter Target="NumberButtonBox.(RelativePanel.RightOf)" Value="{x:Null}" />
   <Setter Target="NumberButtonBox.(RelativePanel.Below)" Value="GridPlaceholder" />
</VisualState.Setters>
Run Code Online (Sandbox Code Playgroud)

其中NumberButtonBox定义为

<Viewbox x:Name="NumberButtonBox" RelativePanel.RightOf="GridPlaceholder" MaxWidth="250" MaxHeight="450" MinWidth="200">
Run Code Online (Sandbox Code Playgroud)

错误在设置器上使用值而{x:Null}不是在另一行上显示.更改Setter行的顺序无效.

是否以这种方式将属性设置为Null以清除此值的正确方法?在运行时它确实有效,只是编辑器有这个问题.

crash blend visual-studio-2015 uwp

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

问号不可见

select case when 'A?B' = 'A?B' then 1 else 0 end
Run Code Online (Sandbox Code Playgroud)

结果:1

为什么第一个字符串中的问号不可见?

有谁知道解决这个问题?

sql

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

Mac OSX 10.5上的Eclipse for Eclipse:"动画启动"错误

我在Eclipse旧版本的MacBook上安装了运行10.5.8的Eclipse/php,这是一个非常糟糕的时间.

我安装了MAMP并运行php 5.3.5.这很好.zend调试器信息在phpinfo()中正确显示,我在正确的位置有dummy.php.配置文件中允许127.0.0.1.

我已经安装了eclipse.我也尝试过"Eclipse for php Developers"v3.0.2.

当我尝试运行或调试脚本时,两个安装都会返回错误.我正在尝试使用Zend Debugger.

错误是:

"动画开始遇到了问题".发生内部错误.发生内部错误.显示java.lang.NullPointerException

我将php可执行文件设置为/Applications/MAMP/bin/php5.3/bin/php(CLI)

建议?

eclipse macos eclipse-pdt

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

如何在字符串中找到两个引号

我试图搜索一个文件,看看是否有任何行包含单词Description1并且如果在该特定行的某处有两个引号直接出现在彼此之后。

我找到了各种删除或替换它们的方法,但我想保留它们。

foreach (var line in File.ReadLines(FileName))
   {
    if (line.Contains ("Description1") )
       {
        MessageBox.Show ("Description1 found");

           if (line.Contains (@"""") )
              {                                                 
               MessageBox.Show ("ERROR! Empty Description1 found.");
              }
        }
}
Run Code Online (Sandbox Code Playgroud)

搜索的文件与此类似

 propertyDescriptor="22004" PropertyName="Description1" PropertyType="Part" PropertyValue="Cat"   
 propertyDescriptor="22004" PropertyName="Description1" PropertyType="Part" PropertyValue=""   
 propertyDescriptor="22006" PropertyName="Description2" PropertyType="Part" PropertyValue=""   

错误检查应该只检测第二行中的错误,其中描述 1 和两个引号都存在。

我的问题是我在文本 Description1 的每个实例上都收到错误消息。

有什么好主意吗?

提前致谢。

c# string parsing quotation-marks

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

当datetime为null时,如何将可空的datetime值转换为string.empty?

我正在读回一个可空的DateTime?属性,然后以短日期格式将该值分配给字符串属性.

我可以将日期时间值转换为短日期字符串并分配给IT_Date_String属性.但是""如果IT_Date为null,我不确定如何为字符串赋值.

你如何转换日期时间?datetime时为string.empty的值?一片空白?

这是linq中的赋值:

var status_list = query_all.ToList().Select(r => new RelStatus
{
    IT_Date_String = r.IT_Date.Value.ToString("yyyy-MM-dd") != null ? r.IT_Date.Value : null
}).ToList();
Run Code Online (Sandbox Code Playgroud)

以及模型中的属性:

public DateTime? IT_Date { get; set; }
public string IT_Date_String { get; set; }
Run Code Online (Sandbox Code Playgroud)

c# datetime nullable conditional-operator

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

C# 使用 array.Where in Arraylist

我在 C# 中有一组带有数组的代码,我需要将数组拆分为更小的数组。声明数组时我没有错误:

List<int> array = new List<int>();
Run Code Online (Sandbox Code Playgroud)

但是,代码执行在数组中提示错误。当我声明为时

var array = new ArrayList();
Run Code Online (Sandbox Code Playgroud)

有什么办法可以使用数组。数组列表中的位置?下面是我的代码:

List<int> array = new List<int>();

for (int i = 0; i <=20; i++){
  if (unitIsPresent) 
  {
    array.add(1);
  } 
  else
  {
    array.add(0)
  }
}

devidedArray = array.Where((e, i) => i >= 5 && i < 10).ToArray();
Run Code Online (Sandbox Code Playgroud)

c# arrays

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

在C#中获取子字符串?

这是一个简单的新手问题.我可能会使用一些复杂的字符串方法(如子字符串和其他方法)来解决这个问题,但我想知道是否有更好的方法来做到这一点.

假设我在C#中有一个字符串:

string foo = "&deg;F";
Run Code Online (Sandbox Code Playgroud)

什么是将其分成两个不同的字符串的最佳方法,其中我有"deg"和"F"?

我看到发生了什么.stackflow正在解释HTML.它实际上是(&符号)deg(分号)F.

对不起,昨晚我发布的时间已经很晚了.

c#

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