将焦点设置为动态加载的DIV中的特定字段的正确方法是什么?
$("#display").load("?control=msgs"); // loads the HTML into the DIV
$('#display').fadeIn("fast"); // display it
$("tex#header").focus(); // ?? neither that
$("input#header").focus(); // ?? nor that
$('#display', '#header').focus() // ?? nor that
$("#header").focus(); // ?? nor that works
Run Code Online (Sandbox Code Playgroud)
将以下HTML提取到displayDIV中:
<div id="display">
<form id="newHeaderForm" class="dataform" action="/" method="post">
<input id="to" type="hidden" value="22" name="to"/>
<dl>
<dt>Header</dt>
<dd>
<input id="header" class="large" type="text" name="header" value="" maxlength="128"/>
</dd>
</form>
</div>
Run Code Online (Sandbox Code Playgroud)
非常感谢!
我有以下结构:
public static class Constants {
public static class Foo {
public static string Bar {
get {
//Constants.Foo.Bar == "FooBar"
return "FooBar";
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我想将它绑定到usercontrol中的按钮.
<Button Content="{Binding Source={x:Static ns:Constants.Foo.Bar}}" />
Run Code Online (Sandbox Code Playgroud)
(其中ns指向定义"常量"的程序集和命名空间).
这导致两个错误:
- "找不到类型'Constants.Foo'.请注意,类型名称区分大小写."
- "未找到类型'ns:Constants.Foo'."
我也尝试过:
<Button Content="{Binding Source={x:Static ns:Constants+Foo.Bar}}" />
Run Code Online (Sandbox Code Playgroud)
这导致一个错误:
- "未找到类型'ns:常量+ Foo'."
是否可以绑定到静态类中的静态类中的静态属性?如果有,怎么样?
通常,如果Visual Studio遇到未处理的异常并显示异常助手窗口,则会中断.
但在某些情况下,Visual Studio只是停止正在运行的程序,并且不会中断或显示异常帮助程序.
正确配置了异常选项(Ctrl + Alt + E):在所有项目上选中"user-unhandled",取消选中"thrown".在调试选项中,我启用了异常助手.
因为它只发生在某些场合,我试图找出视觉工作室何时进入其"故障异常助手状态".
编辑:
看起来故障异常助手ghost只出现在winforms应用程序中,并且只有在有一些外部操作(如调用Web服务或打开数据库连接)之后.
结束编辑
事实证明异常助手工作正常,直到打开ADODB连接:
Run Code Online (Sandbox Code Playgroud)var conn = new ADODB.Connection(); conn.Open("Provider=SQLOLEDB;Server=localhost;Database=db;UID=user;PWD=pw;", "", "", -1); throw new InvalidOperationException();在执行conn.Open语句之后,异常助手将永远不会启动.
这对任何人来说都是熟悉的吗,更重要的是:有没有人能解决这个问题?可以想象,如果应用程序总是退出异常,调试应用程序会变得非常困难.
我正在寻找.NET框架中的静态函数,它接受XML片段和XSLT文件,在内存中应用转换,并返回转换后的XML.
我想这样做:
string rawXml = invoiceTemplateDoc.MainDocumentPart.Document.InnerXml;
rawXml = DoXsltTransformation(rawXml, @"c:\prepare-invoice.xslt"));
// ... do more manipulations on the rawXml
Run Code Online (Sandbox Code Playgroud)
或者,它可以取出并返回XmlNodes,而不是获取和返回字符串.
有这样的功能吗?
在.NET 3.5 Winforms应用程序中,在用户提供用户名和密码后,我在CurrentPrincipal属性中设置了一个自定义主体,如下所示:
My.User.CurrentPrincipal = Service.GetPrincipal(username)
Run Code Online (Sandbox Code Playgroud)
这是在使用Invoke调用的方法中完成的,因为原始线程不是UI线程:
Invoke(New Action(AddressOf doLogin))
Run Code Online (Sandbox Code Playgroud)
但是,当我单击Winforms应用程序中的按钮时,CurrentPrincipal属性已恢复为其默认值,即当前Windows用户.
Dim lPrincipal = My.User.CurrentPrincipal ' not my custom principal
Run Code Online (Sandbox Code Playgroud)
显然,在设置主体时使用Invoke并不能解决问题.是否有另一种方法为CurrentPrincipal应用程序中的所有线程设置属性?
源代码重现问题:
Imports System.Security.Principal
Imports System.Threading
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim lThread As New Thread(AddressOf doLogin)
lThread.Start()
End Sub
Private Sub doLogin()
Invoke(New Action(AddressOf setPrincipal))
End Sub
Private Sub setPrincipal()
My.User.CurrentPrincipal = New CustomPrincipal
MsgBox(My.User.CurrentPrincipal.Identity.AuthenticationType) ' Custom
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, …Run Code Online (Sandbox Code Playgroud) 考虑一个公开抽象类的web方法:
[WebMethod]
public void Save(AbstractEntity obj)
{
// ..
}
Run Code Online (Sandbox Code Playgroud)
有几个继承自AbstractEntitylike的类
public class Patient : AbstractEntity
{
// ...
}
Run Code Online (Sandbox Code Playgroud)
现在我想让webservice使用者创建一个新的Patient对象并保存它:
service.Save(new Patient { Name = "Doe", Number = "1234567" });
Run Code Online (Sandbox Code Playgroud)
因为"保存"采用AbstractEntity,所以客户端没有患者代理.我当然可以创建一个暴露患者的虚拟方法,但我希望有更好的方法.
如何以一种很好的方式公开Patient类和其他未直接在webservice接口中引用的类?
如何使用 libgit2sharp 创建跟踪远程分支的本地分支?git 等价物是:
git branch --track development origin/development
Run Code Online (Sandbox Code Playgroud) 在Angular2 / TypeScript项目中,在显示对话框时,系统将Promise对象返回给调用者,该对话框将在用户关闭对话框后解决。
Promise类接口不会公开resolve()或reject()方法,因此我必须保存对这些方法的引用,以便以后调用它们。
这看起来不对。有没有更好的办法?
class Dialog {
private resolve;
private reject;
show(): Promise<any> {
var p = new Promise<any>((resolve, reject) => {
//save method references for later use
this.resolve = resolve;
this.reject = reject;
});
return p;
}
close() {
this.resolve();
}
}
Run Code Online (Sandbox Code Playgroud) .net ×4
c# ×3
.net-2.0 ×1
angular ×1
asmx ×1
binding ×1
focus ×1
html ×1
javascript ×1
jquery ×1
libgit2sharp ×1
promise ×1
setfocus ×1
typescript ×1
vb.net ×1
web-services ×1
winforms ×1
wpf ×1
xml ×1
xslt ×1