我正在尝试使用水印用于jquery的asp.net文本框控件,下面是我的代码,我看到我的textarea文本框上的标题但是当我关注或点击文本框时水印不清楚.
我从这里得到了剧本.http://www.ajaxblender.com/howto-add-hints-form-auto-focus-using-javascript.html
<asp:TextBox runat="server" ID="txtNew" class="auto-hint" title="Enter here ..."
TextMode="MultiLine" Rows="7" Width="100%"></asp:TextBox>
<script type="text/javascript">
$(document).ready(function () {
// Focus auto-focus fields
$('.auto-focus:first').focus();
// Initialize auto-hint fields
$('INPUT.auto-hint, TEXTAREA.auto-hint').focus(function () {
if ($(this).val() == $(this).attr('title')) {
$(this).val('');
$(this).removeClass('auto-hint');
}
});
$('INPUT.auto-hint, TEXTAREA.auto-hint').blur(function () {
if ($(this).val() == '' && $(this).attr('title') != '') {
$(this).val($(this).attr('title'));
$(this).addClass('auto-hint');
}
});
$('INPUT.auto-hint, TEXTAREA.auto-hint').each(function () {
if ($(this).attr('title') == '') { return; }
if ($(this).val() == '') { $(this).val($(this).attr('title')); }
else { $(this).removeClass('auto-hint'); }
}); …Run Code Online (Sandbox Code Playgroud) 我正在使用此代码,但它返回带有url的图像名称
IWebElement element = driver.FindElement(By.XPath("Your xpath"));
string path = element.GetAttribute("src");
Run Code Online (Sandbox Code Playgroud)
结果:
http://nameofthehost/imagename.jpg
Run Code Online (Sandbox Code Playgroud)
我想要的只是吐我的src名字,我该怎么做?
我正在设置Selenium Grid服务器并且我已经在我的本地机器上成功完成了,我想知道如何给出主机名,所以如果其他测试人员想要注册到集线器他们应该能够做到这一点,这就是我所做的至今:
在我的本地机器上(假设我将允许其他测试人员在这里注册节点)
在我的本地计算机上启动集线器:
java -jar selenium-server-standalone-2.21.0.jar -hub
Run Code Online (Sandbox Code Playgroud)
启动节点
java -jar selenium-server-standalone-2.21.0.jar -role node -hub localhost:4444/grid/register
Run Code Online (Sandbox Code Playgroud)
我查看集线器的状态:localhost:4444/grid/console
现在,我的问题是:如何注册another machine?
在我的另一台机器上,我已经下载了selenium-server-standalone jar文件并运行了这个命令
java -jar selenium-server-standalone-2.21.0.jar -role node -hub localhost:4444/grid/register
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
hub down or not responding
Run Code Online (Sandbox Code Playgroud)
我知道我不应该从其他机器给localhost,我在这里很困惑.
如何从输入字段中提取文本?我尝试使用XPath/CSSSelector,但我得到一个空文本,因为它是一个输入字段.
这是我的HTML代码:
<div>
<input type="text" style="width:110px;" class="display">
</div>
Run Code Online (Sandbox Code Playgroud)
结果:195行中的1到50行
以下是输入字段的屏幕截图:

我正在使用Json.NetDeserializeObject Json数据到对象/集合(列表)
我不确定我做错了什么,我试过这个:
List<LanguageObject> lang = JsonConvert.DeserializeObject<List<LanguageObject>>(jsonData);
Run Code Online (Sandbox Code Playgroud)
并试过这个:
LanguageObject.Results lang = JsonConvert.DeserializeObject<LanguageObject.Results>(jsonData);
Run Code Online (Sandbox Code Playgroud)
我收到这个错误:
Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.List`1[LanguageObject]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.
To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or …Run Code Online (Sandbox Code Playgroud) 我有一个实体集employee_table,我通过excel表获取数据,我已经加载到内存中,用户将单击Save以保存数据库中的更改,并且它首次插入记录并且没有问题.
但是,我该如何仅更新所做的更改?意思是,假设我有10行和5列,10行中说第7行被修改,5列中的第3列被修改,我只需更新那些更改并保留其他值的现有值列.
我可以做检查,if (myexistingItem.Name != dbItem.Name) { //update }但它非常繁琐,效率不高,我确信有更好的方法来处理.
这是我到目前为止所得到的.
var excelData = SessionWrapper.GetSession_Model().DataModel.OrderBy(x => x.LocalName).ToList();;
var dbData = context.employee_master.OrderBy(x => x.localname).ToList();
employee_master = dbEntity = employee_master();
if (dbData.Count > 0)
{
//update
foreach (var dbItem in dbData)
{
foreach(var xlData in excelData)
{
if(dbItem.customer == xlData.Customer)
{
dbEntity.customer = xlData.Customer;
}
//...do check rest of the props....
db.Entry(dbEntity).State = EntityState.Modified;
db.employee_master.Add(dbEntity);
}
}
//save
db.SaveChanges();
}
else
{
//insert
}
Run Code Online (Sandbox Code Playgroud) 我想使用ActionLink而不是普通的html来弹出我的模态窗口,但它的工作正常与纯HTML标签但不与MVC actionlink一起请看下面.
来自:(工作)
<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
Run Code Online (Sandbox Code Playgroud)
到:(错误)
@Html.ActionLink("Edit", "Edit", null, new { id = @item.Id }, new { @data-toggle="modal", @data-target="#myModal" })
Run Code Online (Sandbox Code Playgroud)
无效的匿名类型成员声明符.必须使用成员分配,简单名称或成员访问声明匿名类型成员.
我刚刚开始使用Moq ver(3.1)并且我已经阅读了博客,而不是......不管怎样......我想直到你弄脏你的手你才会学到:)
好的,这是我正在测试...
var newProduct = new Mock<IPartialPerson>();
newProduct.SetupGet(p => p.FirstName).Returns("FirstName");
newProduct.SetupGet(p => p.MiddleName).Returns("MiddleName");
newProduct.SetupGet(p => p.LastName).Returns("LastName");
newProduct.SetupGet(p => p.EmailAddress).Returns("EmailAddress@hotmail.com");
newProduct.SetupGet(p => p.UserID).Returns("UserID");
//mock Escort repository
var mockEscortRepository = new Mock<IEscortRepository>();
mockEscortRepository.Setup(p => p.LoadAllEscorts())
.Returns(newProduct.Object); //error
Run Code Online (Sandbox Code Playgroud)
错误1'Moq.Language.IReturns> .Returns(System.Collections.Generic.List)'的最佳重载方法匹配有一些无效的参数
错误2参数'1':无法从'App.Model.Interface.IPartialPerson'转换为'System.Collections.Generic.List'
public interface IPartialPerson
{
string FirstName { get; }
string MiddleName { get; }
string LastName { get; }
string EmailAddress { get; }
string FullName { get; }
string UserID { get; }
}
public interface IEscortRepository
{
List<PartialPerson> LoadAllEscorts(); …Run Code Online (Sandbox Code Playgroud) 有没有办法,我可以.aspx page使用Internet Explorer 8 在我的"为网站启用兼容性视图"中添加标记?没有使用点击浏览器上的"兼容性"图标?
我正在尝试读取xml文件但不知何故我收到此错误:参数数量无效.
<script type="text/javascript">
//<![CDATA[
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
}
else {
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET", "employee.XML", false);
xmlhttp.send();
xmlDoc = xmlhttp.responseXML;
var empid= xmlDoc.getElementsByTagName("empid");
var total = placeMarks.length;
var names = xmlDoc.getElementsByTagName("Name");
var designation= xmlDoc.getElementsByTagName("designation");
var phone= xmlDoc.getElementsByTagName("phone");
.....
</script>
Run Code Online (Sandbox Code Playgroud)
XML数据:
<employee>
<emp id="1007">
<name>John Chamber</name>
<designation>Web Expert1</designation>
<phone>555-55-555</phone>
<name>John D</name>
<designation>Web123123</designation>
<phone>555-55-555</phone>
<name>Chamber</name>
<designation>Web Expert</designation>
<phone>555-55-555</phone>
<name>Thomas</name>
<designation>TESTTEST</designation>
<phone>555-55-555</phone>
</emp>
</employee>
Run Code Online (Sandbox Code Playgroud) asp.net ×2
asp.net-mvc ×2
javascript ×2
selenium ×2
webdriver ×2
actionlink ×1
c# ×1
jquery ×1
json ×1
json.net ×1
moq ×1
unit-testing ×1
xml ×1