- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 asp:DataList 中有一个 div,其中包含一些其他 div。我尝试通过 document.getElementByID("")
查找 div。
它调用:无法获取未定义或空引用的属性“style”。
结果我知道 .getElementById
找不到它。那我怎样才能得到它们呢?我试图通过旧帖子找到我的数据列表,但没有一个符合我的问题。
注意:我的 div
应该被拖动,它们确实如此,但由于这个问题我无法获取它们的位置值。
代码:
function FullDragging() {
// some code
var dd = document.getElementById("DesigningDiv"); // frame
var logoObject = document.getElementById("logoObject"); // draggable element
var nameObject = document.getElementById("nameObject"); // draggable element
function getDesigningDivSize() {
var dd = document.getElementById("DesigningDiv");
var aspDesigningDivHF = document.getElementById('<%=aspDesigningDivHF.ClientID %>'); // hidden-field which sends the changes in client-side to the server.
aspDesigningDivHF.value = parseInt(dd.style.width) + "," + parseInt(dd.style.height);
}
}
window.onload = FullDragging;
因为调用了onload函数,所以onload也会出现错误。
HTML:
<asp:DataList ID="DataList1" runat="server" DataKeyField="ProductID" Height="400px" Width="1400px" OnEditCommand="DataList1_EditCommand" OnItemCommand="DataList1_ItemCommand" CellPadding="40" RepeatColumns="2" RepeatDirection="Horizontal" OnCancelCommand="DataList1_CancelCommand" OnItemDataBound="DataList1_ItemDataBound" OnUpdateCommand="DataList1_UpdateCommand">
<ItemTemplate> ... </ItemTemplate>
<EditItemTemplate>
<div id="DesigningDiv" style="height: 150px; width: 262.5px; border-style: groove; border-color: inherit; border-width: 1px; position: relative; height: 158px; width: 270px; background-color: #FFFFFF; visibility: hidden">
<div id="logoObject" style="width: 51px; top: 31px; position: absolute; height: 34px; font-family: 'times New Roman', Times, serif; font-size: xx-large; font-weight: bold; color: #333333; cursor: move; left: 187px;"> logo </div>
<div id="nameObject" style="width: 61px; top: 31px; position: absolute; height: 22px; font-family: 'times New Roman', Times, serif; color: #666666; font-size: large; cursor: move; font-weight: bold; left: 29px; bottom: 105px;"> full name </div>
</EditItemTemplate>
</asp:DataList>
最佳答案
有几个问题,您不应该使用静态 ID 填充项目模板,因为 ID 只能在 html 文档中出现一次。
考虑对这些 div 应用一个类并以这种方式引用它们。
渲染页面后,右键单击并检查这些元素之一。 ASP 可能会向您的 ID 添加额外的前缀,因为它是数据列表的一部分(例如,一旦页面加载,Visual Studio 中的 DivLabel1 就会变成 DataList1_DivLabel1),javascript 不参与此转换,因此您最好按类引用这些项目
关于javascript - 在javascript中的DataList中查找Div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23185239/
我正在尝试为模板中循环内的循环创建一个带有子 DataList 的 DataList: public function getAllCategoriesAndEntrys(){ $catego
griview优点:功能最强大,提供分页,编辑,删除,选择等等很多功能,使用最方便,直接拖拽到页面上,建立新的数据源,点几下鼠标就可以维护一个表的浏览、删除和修改了,而且是分页的哦。(增加我还没搞明
我将 10 个选项传递给数据列表,这些选项在下拉列表中显示良好。但有时我会在选项列表底部获得更多由水平线分隔的选项(Chrome 可能正在缓存或重复显示某些选项)。我不明白为什么 chrome 显示这
是否可以将图像添加到数据列表选项中?我正在为我的用户构建一个搜索,我希望头像与姓名和简介一起显示在数据列表中,就像在 Twitter 或 Facebook 上一样。 $avatar变量具有指向图像的链
我在 VueJS 中使用 datalist 搜索时遇到 input 问题,为什么当我用鼠标单击或在 datalist 上的选项之一上输入时,我的函数 getData() 被调用到 @click 和 @
我正在使用 .NET aspx 进行编程。在 asp:DataList 组件中,我想均匀分布列,即使并非所有列都分配有 ItemTemplate。 例如 ... 在运行时,绑定(bind)到数
给定一个表格: console.log(document.getElementById('f').elements['a']); console.log(document.getElementById
Datalist 属性在 Google chrome 中不工作,在 Firefox 中工作正常 请看这里http://prntscr.com/arny81 提前感谢您的帮助。 HTML
我有一个如下的模板: {{i-1}} 还有一个像这样的 TS 文件: import {Component, OnInit} from '@angular/co
使用这个例子http://www.w3schools.com/tags/tag_datalist.asp- 我在浏览器中没有问题,但它似乎在打包的应用程序中不起作用。 我使用的是 Chrome v26
代码如下: PEAEWebSiteDataContext context = new PEAEWebSiteDataContext(); &nbs
如何禁用 Datalist 中的选项? London Zurich Italian Turin Milan Rome Naples French Bordeaux Lion Paris 我尝试
所有实现 IEnumerable 接口(interface)的类型都可以用于 DataList 的 DataSource。例如列表。但是我们将为 ItemTemplate 中的数据绑定(bind)表达
我正在使用以下 Javascript 函数来填充数据列表: function GetDropDownData(f) { $.ajax({ url: '/Rentals/Base
在我的数据列表选项中,有英语和韩语的值。 这是示例: (<-This value is apple in Korean) 当我尝试在输入框中使用韩文字母搜索值时,没有显示任何内容,仅以英文值工
我已经在数据列表文件夹上应用了规则,就像在每个项目创建上一样,它应该向相应的人发送一封电子邮件。 下面是相同的脚本: function main() { var site = siteServ
我有一个页面,用户可以在数据列表控件中选择不同的文档文件。使用预渲染事件处理程序根据类别对文档进行分类。文档是根据复选框控件(而不是复选框列表)选择的。到目前为止,一切都很好。接下来我想要发生的事情是
我的页面上有 DataList,用于显示来自数据库的记录。我已关注this使用 DataList 实现分页的教程。 它在第一页上显示 5 条记录,但在下一页上,数据列表加载为空。我可以通过单击“下一步
我在DataList中有一个UserControl,我根据DataList数据的PrimeryKey填充用户控件内的控件。第一次加载程序的行为符合预期,但当用户更改页面索引时,所有 MessageID
我有一个数据列表,在它的标题模板中有一个链接按钮。在我的代码隐藏文件中,我像往常一样写: ((LinkButton)(DataList1.FindControl("LinkButton1"))).En
我是一名优秀的程序员,十分优秀!