小编Gra*_*ray的帖子

<optgroup label ='-------'> </ optgroup>给出了xhtml验证错误

Error: End tag for 'optgroup' which is not finished. You have probably failed to 
include a required child element. Hence the parent element is "not finished",
 not complete. 
Run Code Online (Sandbox Code Playgroud)

我想在select选项中实现类似的功能.

USA
UK
--
Afghanistan
Run Code Online (Sandbox Code Playgroud)

我想把几个重要国家放在首位,然后是一个不可选择的分隔符,然后排序其余国家的列表.

我把这个分隔符用空'optgroup'.虽然它在所有浏览器中都运行良好,但我得到验证错误.

可能有哪些其他方法来实现这一点?

html css optgroup

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

当IEnumerable包含null时使用什么异常类

我已多次看到以下异常情况

    public SomeClass(IEnumerable<T> someValues)
    {
        if (null == someValues)
        {
            throw new ArgumentNullException("someValues");
        }

        int counter = 0;
        foreach (T value in someValues)
        {
            if (null == value)
            {
                string msg = counter + "th value was null";
                // What exception class to use?
                throw new ArgumentException(msg, "someValues");
            }
            counter++;
        }
    }
Run Code Online (Sandbox Code Playgroud)

是否有处理这些案件的指导方针?通常,有任何描述"异常样式"的指南比MSDN文档更详细

.net c# exception

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

如果有人提交“恶意软件” nuget包怎么办?

我检查了Nuget提交过程,但未发现有关基本检查或审阅过程的任何信息。

那么,如果有人提交了一个电子邮件模板帮助程序包,但实际上确实进行了电子邮件嗅探,那该怎么办?

如果我错过了这里,请纠正我。

c# security nuget nuget-package

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

如何在不使用乘法(*)符号的情况下乘以十进制数

任何人都可以建议我一种方法来乘以十进制数而不使用乘法(*)符号.我知道它看起来像家庭作业,但我只是想知道如何实现这一目标.我已经为正负整数做了这个,如下所示:

int first = 2;
int second =2;
int result = 0;
bool isNegative = false;

if (first < 0)
{
    first = Math.Abs(first);
    isNegative = true;
}
if (second < 0)
{
    second = Math.Abs(second);
    isNegative = true;
}

for (int i = 1; i <= second; i++)
{
    result += first;
}

if (isNegative)
    result = -Math.Abs(result);
Run Code Online (Sandbox Code Playgroud)

想要将其乘以小数:

decimal third = 1.1;
decimal fourth = 1.2;
Run Code Online (Sandbox Code Playgroud)

谢谢

c#

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

jquery如何从搜索框中获取字符串

我正在研究jquery搜索框.

从html获取string var我遇到了麻烦.

在我的html文件中.

我有..

<header>
  <div id="searchBox">
    <form name="searchForm">
      <div>
        <i class="icon-search icon-large icon-height"></i>
        <input name="searchfield" type="search" size="20" maxlength="30">
      </div>
    </form>
  </div>
</header>
Run Code Online (Sandbox Code Playgroud)

在我的jquery文件中

$(".icon-search").click(function() {
  var searchstring  = $(this).text('#searchfield');// $('#searchfield');
  searchstring.focus();
  //$('#searchBox').html($('input:searchfield').val());
  alert("searchfield.  " + searchstring +  " hahah");
});
Run Code Online (Sandbox Code Playgroud)

当我点击搜索一些字符串.

它显示了Object对象而不是一些字符串.

我不确定如何将对象转换为字符串.

有谁知道如何转换它?

jquery search-box

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

错误属性或索引器不能在此上下文中使用,因为set访问器不可访问

我有以下代码:

using System;
using System.Collections.Generic;
using System.Text;
using ProjectBase.Utils;

namespace EnterpriseSample.Core.Domain
{
    public class Notifikasi : DomainObject<string>, IHasAssignedId<string>
    {
        public string Name { get; set; }
        public string Description { get; set; }
        public DateTime StartDate { get; set; }
        public DateTime EndDate { get; set; }
        public DateTime CreatedDate { get; set; }
        public string CreatedBy { get; set; }
        public DateTime UpdateDate { get; set; }
        public string UpdateBy { get; set; }

        public void SetAssignedIdTo(string assignedId)
        { …
Run Code Online (Sandbox Code Playgroud)

c#

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

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

从 URL 显示由 decodeURIComponent 解码的 HTML 代码是否安全?

一般的

我不确定以这种方式显示用户输入的一些文本是否安全:

来自 URL 的参数由decodeURIComponent(). 之后,换行符使用 替换text.replace(/\n/g, '<br/>')
结果字符串显示在 OpenLayers 标记中。

通过这种方式,来自用户的 HTML 被嵌入到网页中。

具体例子

http://map.openseamap.org允许创建永久链接(顶部菜单 > 工具 > 永久链接)
该站点解码如上所示的 URL 并在页面上显示一个标记。

示例:http :
//map.openseamap.org/map/?zoom=15&​​mlat=53.62053&mlon=11.46929&mtext=%3Cscript%3E%0A%20alert(%27Hello%20World!%27)%3B%0A%3C%2Fscript %3E&layers=BTFFFFFFFFF0FFFFFFFF

包含:

<script>
    alert('Hello World!');
</script>
Run Code Online (Sandbox Code Playgroud)

代码嵌入在页面中,但不会执行。

这种显示文本的方式可以被利用吗?

你可以在这里找到该站点的代码:http :
//github.com/OpenSeaMap/online_chart

解码代码在 index.php 第 138 行:http :
//github.com/OpenSeaMap/online_chart/blob/master/index.php#L137

如果您有更好的解决方案,欢迎提出请求!

html javascript security xss openlayers

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

如何解决此错误 - 没有属性"onFocus"

我收到一个错误称为没有属性"onFocus".我有一个代码如下:

<input name="name" id="name" class="small required name" type="text" value="Name:" onFocus="if(this.value='Name:'){this.value=''}" />

我尝试在http://validator.w3.org/验证我的网站,我收到了这些错误.任何人都可以帮我解决这个问题吗?

html javascript

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

为什么我无法将sprintf的变量字符串传递给perl脚本?

我带来了以下perl问题.把这段代码放到test.pl中

my $str=shift;

printf "$str", @ARGV;
Run Code Online (Sandbox Code Playgroud)

然后像这样运行:

perl test.pl "x\tx%s\n%s" one two three
Run Code Online (Sandbox Code Playgroud)

我的预期输出应该是:

x    xone
two
Run Code Online (Sandbox Code Playgroud)

相反,我得到了

x\sxone\ntwo
Run Code Online (Sandbox Code Playgroud)

我哪里错了?

perl printf

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