小编Sve*_*ang的帖子

AJAX PageMethods与Routing冲突?

编辑:Post底部的最新信息.

我在页面上有一个更新面板,我强制用__doPostBack回发.

当我浏览它时,一切正常 /path/page.aspx.

但是,只要我通过像/otherpath/page回发这样的路径访问页面就不会发生.

有什么建议?

这是我的JS文件:

/// <reference name="MicrosoftAjax.js"/>
function Check() {
   // Call the static page method.
   PageMethods.GetLatestHeadlineTick(OnSucceeded, OnFailed);
}

function OnSucceeded(result, userContext, methodName) {
   // Parse the page method's result and the embedded
   //  hidden value to integers for comparison.
   var LatestTick = parseInt(result);
   var LatestDisplayTick = parseInt($get('LatestDisplayTick').value);

   // If the page method's return value is larger than 
   //  the embedded latest display tick, refresh the panel.
   if (LatestTick > LatestDisplayTick)
    __doPostBack('UpdatePanel1', '');
   // Else, …
Run Code Online (Sandbox Code Playgroud)

.net javascript ajax url-routing dopostback

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

6位int的正则表达式,不能是连续或重复的数字?

我试图得到一个正则表达式,检查以确保提供的int是6位数,它不是顺序的,也不包含所有重复的数字,无论是按升序还是降序.我真的不在乎正则表达式是否返回非允许数字的匹配项,或者如果允许则返回原始数字的匹配项.

所以例如所有这些数字都是我不需要通过正则表达式验证的:

  • 123456
  • 654321
  • 069
  • 456789
  • 2435
  • 444444

虽然这些数字会通过:

  • 044346
  • 666605
  • 042004
  • 678853

谢谢.

编辑:出现正则表达式不适合这个.很多很好的答案和多个是正确的,所以我只是跟谁先回答,谢谢大家!

.net c# regex

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

Jquery,检查charAt()是否等于unicode字符?

我有一个可折叠的链接,上面有unicode箭头

?This is a collapsible link
Run Code Online (Sandbox Code Playgroud)

当有人点击它时,我希望它变成向下箭头▼.但是我无法弄清楚如何解析替换这个角色.

这是我的代码:

function CollapsibleContainerTitleClickApp(){
     $(".collapsibleContainerContent.app", $(this).parent()).slideToggle();
     alert($(this).text().trim().charAt(0));
     if ($(this).text.trim().charAt(0) == "\u25B8"{
        alert("inside the if statement");
        $(this).text($(this).text().replace("\u25B8", "\u25BE"));
     }else{
        $(this).text($(this).text().replace("\u25BE", "\u25B8"));
}
Run Code Online (Sandbox Code Playgroud)

现在,第一个警报总是弹出,因为实际箭头(►)和查看源也有实际箭头.如何查看第一个字符是否为一个箭头,如果是,请将其替换为另一个箭头?第二个警告语句永远不会触发,因此它永远不会传递if的条件.

javascript string unicode jquery

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

删除所有空HTML标记?

我想象一个函数,我想使用正则表达式,它将是递归的实例,如<p><strong></strong></p>删除字符串中的所有空HTML标记.如果可能的话,这必须考虑空白.没有疯狂的实例,其中<character在属性值中使用.

我在正则表达式上非常糟糕,但我想这是可能的.你怎么能这样做?

这是我到目前为止的方法:

Public Shared Function stripEmptyHtmlTags(ByVal html As String) As String
    Dim newHtml As String = Regex.Replace(html, "/(<.+?>\s*</.+?>)/Usi", "")

    If html <> newHtml Then
        newHtml = stripEmptyHtmlTags(newHtml)
    End If

    Return newHtml
End Function
Run Code Online (Sandbox Code Playgroud)

但是我现在的正则表达式是PHP格式,它似乎没有工作.我不熟悉.NET正则表达式语法.

对于所有那些不使用正则表达式的人:我很好奇这种模式无论如何.当然有一种模式可以匹配所有打开/关闭开始标签与标签之间的任何数量的空白(或没有)?我已经看到正则表达式匹配HTML标签与任意数量的属性,一个空标签(如只是<p></p>)等.

到目前为止,我已经在上面的方法中尝试了以下正则表达式模式无效(因为,我有一个带有空段落标记的文本字符串,甚至没有被删除.)

Regex.Replace(html, "/(<.+?>\s*</.+?>)/Usi", "")

Regex.Replace(html, "(<.+?>\s*</.+?>)", "")

Regex.Replace(html, "%<(\w+)\b[^>]*>\s*</\1\s*>%", "")

Regex.Replace(html, "<\w+\s*>\s*</\1\s*>", "")

.net regex recursion html-parsing recursive-regex

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

.each()在一次交互后停止了吗?

这么简单的问题,但我无法弄明白......

function pageLoad() {
    runDatepickers();
    $("#btnSubmit").click(function () {
        $('span[id^="rfv"]').css("display", "block");
        alert("Submit was clicked");
        $('span[id^="rfv"]').each(function () {
            alert($(this).attr("id"));
            if ($(this).css("display") = "inline") {
                alert("display is inline");
                $(this).css("display", "block");
            }
        });
    });
};
Run Code Online (Sandbox Code Playgroud)

这在一次迭代后停止,我在页面上有多个以"rfv"开头的跨度,第一个语句$('span[id^="rfv"]').css("display", "block");正确选择并更改所有这些元素的显示,但根据我的警报,当我进入每个时,它只匹配第一个元素,就是它.我在这里失踪了什么?

each jquery

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

LINQ GroupBy 3个房产?

我有以下课程:

public class ProductInventory : Entity
{
    public virtual Product Product { get; set; }
    public DateTime ExpirationDate { get; set; }
    public Manager Manager { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

和我的ViewModel中使用的类看起来像这样:

 public class ProductInventoryCountModel
{
    public Product Product { get; set; }
    public DateTime ExpirationDate { get; set; }
    public int Count { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

我希望得到一个输出,Dictionary<Manager, List<ProductInventoryCountModel>它基本上按经理显示产品,然后是到期日期,这样我就可以打印出类似这样的实际数据:

ManagerBoB

 --ProductA, Expires 8/15/13, Count: 10
 --ProductA, Expires 10/10/13, Count: 40
 --ProductB, Expires 6/13/13, Count: 30

ManagerTim

 --ProductA, Expires …
Run Code Online (Sandbox Code Playgroud)

c# linq entity-framework

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