如何设置值/文本div?
<div id="numberOf"></div>
$("#btn").click(function (event) {
$.getJSON('http://host/myServiceImpl.svc/GetCount?method=?',
{ id '1' },
function (data) {
alert(data);
$("#numberOf").val = data;
}
);
});
Run Code Online (Sandbox Code Playgroud) 我有一堆单元测试我正在测试,我把断点放在unitest代码上,当我运行CTL+R,T而不是停在断点上它只是执行代码,我试图调试unittest代码因为它失败...任何救命?
我正在使用VS 2010专业版
我在sql server及其可选字段中有一个datetime列,如果用户决定不输入,那么我想在表中插入值为NULL,我定义如下:
@deadlineDate datetime = null
Run Code Online (Sandbox Code Playgroud)
当我插入到SQL服务器时,我在asp.net中有这个代码
private DateTime? GetDeadlineDate()
{
DateTime? getDeadlineDate = null;
if (!string.IsNullOrEmpty(DeadlineDate.SelectedDate))
{
getDeadlineDate = DateTime.Parse(DeadlineDate.SelectedDate).Date;
}
if (!getDeadlineDate.HasValue)
{
return null;
}
return getDeadlineDate.Value;
}
Run Code Online (Sandbox Code Playgroud)
但问题是:插入
1900-01-01 00:00:00.000
Run Code Online (Sandbox Code Playgroud)
在sql表而不是 NULL
我在这做错了什么?
更新:
private DateTime? GetDeadlineDate()
{
DateTime? getDeadlineDate = null;
if (!string.IsNullOrEmpty(DeadlineDate.SelectedDate))
{
getDeadlineDate = DateTime.Parse(DeadlineDate.SelectedDate).Date;
}
if (!getDeadlineDate.HasValue)
{
return DBNull.Value; //throws error....
}
return getDeadlineDate.Value;
}
Run Code Online (Sandbox Code Playgroud) ReporterTbl与...有一对多的关系AttachmentTbl.
在ReporterTbl,我有一个ID(101),我可以有AttachmentTbl多个Attachment与之相关的ReporterTbl.Id
SELECT
ISNULL(ReporterTbl.Id, 0) AS Id,
CONVERT(char(10), ReporterTbl.StartDate, 101) AS StartDate,
ISNULL(ReporterTbl.PriorityId, 0) AS PriorityId,
ISNULL(dbo.ReporterTbl.PriorityDesc, '') AS PriorityDesc,
(select
ReporterTbl.Id,
COUNT(dbo.AttachmentTbl.Id) AS attachment_Id
FROM
dbo.AttachmentTbl RIGHT OUTER JOIN
ReporterTbl ON dbo.AttachmentTbl.Id = ReporterTbl.Id
GROUP BY ReporterTbl.Id) AS IsAttachment
)
Run Code Online (Sandbox Code Playgroud)
基本上,我想知道的是ReporterTbl.ID,Attachment我有多少?
表结构:
ReporterTbl
Id int {**PrimaryKey**}
StartDate datetime
PriorityId int
PriorityDesc varchar(500
AttachmentTbl:
AttachmentId indentity
Id {**FK to ReproterTbl**}
Filename
Content
...
Run Code Online (Sandbox Code Playgroud) 我该如何优化这段代码?我不喜欢有案例陈述,有没有办法可以改进这段代码?
protected void ddlFilterResultBy_SelectedIndexChanged(object sender, EventArgs e)
{
string selVal = ddlFilterResultBy.SelectedValue.ToString().ToLower();
switch (selVal)
{
case "date":
pnlDate.Visible = true;
pnlSubject.Visible = false;
pnlofficer.Visible = false;
pnlCIA.Visible = false;
pnlMedia.Visible = false;
pnlStatus.Visible = false;
break;
case "subject":
pnlDate.Visible = false;
pnlSubject.Visible = true;
pnlofficer.Visible = false;
pnlCIA.Visible = false;
pnlMedia.Visible = false;
pnlStatus.Visible = false;
break;
case "officer":
pnlDate.Visible = false;
pnlSubject.Visible = false;
pnlofficer.Visible = true;
pnlCIA.Visible = false;
pnlMedia.Visible = false;
pnlStatus.Visible = false;
break;
case "status": …Run Code Online (Sandbox Code Playgroud) DECLARE @ID BIGINT
set @ID = 1323
UPDATE School
SET RegistrationFee = 'fee_' + @ID --<<<<error
Where SchoolRegistrationId = 123
Run Code Online (Sandbox Code Playgroud)
将数据类型varchar转换为bigint时出错.
我正在使用Selenium 2测试(用C#编写),从"选择"控件中选择值.选择会导致回发到服务器,从而更新页面状态.因此,thread.sleep在选择等待页面更改的值后,我执行手动wait().它可以与Thread.Sleep一起使用.但是,Thread.Sleep使用有很多正当理由是一个坏主意,所以当我拿出我Thread.Sleep的所有代码行时,我的所有测试用例都崩溃了,我尝试过WebDriverWait,隐式和明确地没有工作,非常沮丧
下面是我试过的示例代码....
// WebDriverWait
public IWebElement WaitForElement(By by)
{
// Tell webdriver to wait
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));
wait.PollingInterval = TimeSpan.FromSeconds(2);
wait.IgnoreExceptionTypes(typeof(NoSuchElementException), typeof(NoSuchFrameException));
wait.IgnoreExceptionTypes(typeof(StaleElementReferenceException), typeof(StaleElementReferenceException));
IWebElement myWait = wait.Until(x => x.FindElement(by));
return myWait;
}
Run Code Online (Sandbox Code Playgroud)
试过这个:
WebDriverWait wait = new WebDriverWait(new SystemClock(), driver, TimeSpan.FromSeconds(30), TimeSpan.FromMilliseconds(100));
Run Code Online (Sandbox Code Playgroud)
//隐式:
driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 30));
Run Code Online (Sandbox Code Playgroud)
//显式等待:
IWebDriver driver = new FirefoxDriver();
driver.Url = "http://somedomain/url_that_delays_loading";
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));
IWebElement myDynamicElement = wait.Until<IWebElement>((d) =>
{
return …Run Code Online (Sandbox Code Playgroud) 我正在使用selenium 2(WebDriver).
我找到一个按钮并按脚本单击:
driver.findElement(By.cssSelector("button:contains('Run Query')"));
Run Code Online (Sandbox Code Playgroud)
要么
driver.findElement(By.cssSelector("css=.gwt-Button:contains('Run Query')"))
Run Code Online (Sandbox Code Playgroud)
其html如下:
<button type="button" class="gwt-Button" id="ext-gen362">Run Query</
button>
Run Code Online (Sandbox Code Playgroud)
由于id是动态生成的,我无法使用ID.
有没有办法使用像contains这样的东西cssSelector?这可能吗?
更新:
在我的html页面上,我使用如下:
<section ng-repeat="template in templates">
<ng-include src="template"></ng-include>
</section>
Run Code Online (Sandbox Code Playgroud)
但问题是我需要特定顺序的特定文件,所以有没有办法控制顺序渲染的方式?
我试图通过一个对象来命令我该如何做到这一点,我在网上搜索后才发布它.
function MyCtrl($scope) {
$scope.templates = {
template_address: "../template/address.html",
template_book: "../template/book.html",
template_create: "../template/create.html"
};
<div ng-app ng-controller="MyCtrl">
<ul>
<li ng-repeat="(name, path) in templates">{{name}}: {{path}}</li>
</ul>
</div>
Run Code Online (Sandbox Code Playgroud)
我有一个简单的页面验证字段,类似这样:
employee.html并验证字段但如果我添加了相同的代码并使用ng-include调用相同的页面验证不起作用
without ng-include 验证工作:
<form name="form" class="form-horizontal" ng-validate="create(data)" novalidate>
<div class="row">
<div class="col-xs-6">
<div class="form-group">
<label for="" class="col-xs-6 control-label">First Name:</label>
<div class="col-xs-6">
<input name="first_name" type="text" class="form-control" ng-model="data.first_name" placeholder="First name" ng-required="true">
<div class="alert alert-danger" ng-show="form.$submitted && form.first_name.$error.required">Enter first name.</div>
</div>
</div>
</div>
</div>
</form>
Run Code Online (Sandbox Code Playgroud)
with ng-include 验证不起作用:
dashboard.html
<div class="container">
....................
..................
<ng-include src="employee.html"></ng-include>
</div>
Run Code Online (Sandbox Code Playgroud)
我的问题是:如何在ng-include中进行验证?