[英]Why can't I edit position of dropdownlist in ASP.net?
使用Visual Studio时,我无法在asp.net中的源代码视图中编辑dropdownlist控件“ Top”字段(突出显示为棕色):
我可以编辑下面的图像控件!
<asp:DropDownList ID="DropDownList1" runat="server"
DataSourceID="SqlDataSource1" DataTextField="AccountIdent"
DataValueField="AccountIdent"
style="top: 102px; left: 0px; position: absolute; height: 24px; width: 114px; z-index: 1;">
</asp:DropDownList>
<asp:Image ID="Image3" runat="server"
style="top: 0px; left: 0px; position: absolute; height: 23px; width: 47px" />
为什么是这样?
我认为发生这种情况是因为asp:Image
将生成单个标签<img/>
,而下拉列表将生成更多标签。
您应该使用CssClasses,如果您不想将其放在另一个文件中,则可以在页面中使用它(在其他文件中维护css总是一个好主意),例如:
<style type="text/css">
.drop{
top: 102px; left: 0px; position: absolute; height: 24px; width: 114px; z-index: 1;
}
.image{
top: 0px; left: 0px; position: absolute; height: 23px; width: 47px
}
</style>
<asp:DropDownList ID="DropDownList1" runat="server"
DataSourceID="SqlDataSource1" DataTextField="AccountIdent"
DataValueField="AccountIdent" CssClass="drop">
</asp:DropDownList>
<asp:Image ID="Image3" runat="server" CssClass="image"/>
DropdownList
没有Style
属性,这就是为什么你不能设置it.For解决方案创建一个CSS类的属性和设置cssClass
的dropdownList
的那类
喜欢
<style>
.anyname {
top: 102px; left: 0px; position: absolute; height: 24px; width: 114px; z-index: 1;
}
</style>
并在下拉列表中
<asp:DropDownList ID="DropDownList1" runat="server"
DataSourceID="SqlDataSource1" DataTextField="AccountIdent"
DataValueField="AccountIdent" CssClass="anyname">
</asp:DropDownList>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.