在 ASP.NET Web 表单上保持 DevExpress 控件内联
我刚刚用 DevExpress 控件替换了一个小型 Web 项目中的 Telerik 控件,但现在,尽管我添加了内联显示 div 作为容器,但这些控件不再内联呈现。可能是什么导致了这种情况,我该怎么做才能使这些错误的控件恢复内联?
<div style="display: inline;">
<label>
Department:</label>
<dx:ASPxComboBox ID="deptCombo" runat="server" AutoPostBack="false" ValueField="DeptId" TextField="DeptName" Width="250px" OnSelectedIndexChanged="deptCombo_SelectedIndexChanged">
</dx:ASPxComboBox>
<label>
Production Date:</label>
<dx:ASPxDateEdit ID="productionDatePicker" runat="server" DisplayFormatString="{0:dd/MM/yyyy}" EditFormat="Custom" EditFormatString="dd/MM/yyyy"
ondatechanged="productionDatePicker_DateChanged">
</dx:ASPxDateEdit>
</div>
I've just replaced Telerik controls in a small web project with DevExpress controls, but now, despite my adding an inline display div as container, these controls are no longer rendered inline. What could have caused this, and what can I do to get these errant controls back inline?
<div style="display: inline;">
<label>
Department:</label>
<dx:ASPxComboBox ID="deptCombo" runat="server" AutoPostBack="false" ValueField="DeptId" TextField="DeptName" Width="250px" OnSelectedIndexChanged="deptCombo_SelectedIndexChanged">
</dx:ASPxComboBox>
<label>
Production Date:</label>
<dx:ASPxDateEdit ID="productionDatePicker" runat="server" DisplayFormatString="{0:dd/MM/yyyy}" EditFormat="Custom" EditFormatString="dd/MM/yyyy"
ondatechanged="productionDatePicker_DateChanged">
</dx:ASPxDateEdit>
</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
听起来 DevX 控件有一些您需要覆盖的 CSS。
对于初学者,我会尝试将 !important 标志添加到样式中:
如果这不起作用,请切换回 RadControls。他们要优越得多:)
Sounds like the DevX controls have some CSS that you'll need to override.
For starters, I'd try adding the !important flag to the style:
If that doesn't work, switch back to the RadControls. They are far superior :)
几乎所有 DevExpress 控件都呈现为表格。这种方法的主要优点是这种方法提供了良好的跨浏览器能力,因为当使用嵌套 div 时,可能很难在所有浏览器中同步它们的位置和大小。然而,使用表格可以让最终用户摆脱这个问题。
[CSS] 在您的 css 上添加此行
[ASPx] 在您想要内联的控件上添加 CssClass="DXControlsInline"
来源: http://www.theedgesearch.com/2016/04/how-to-arrange-devexpress-controls.html
Almost all of DevExpress controls are rendered as tables. The main advantage of this approach is that this way provides good cross-browser capability, since when nested divs are used, it might be hard to synchronize their positions and sizes for all browsers. However, using tables allows end-users to get rid of this problem.
[CSS] add this line on your css
[ASPx] add CssClass="DXControlsInline" on controls you want to make inline
Source : http://www.theedgesearch.com/2016/04/how-to-arrange-devexpress-controls.html
该任务与我们的控件没有直接关系,并且可以在没有控件的情况下以类似的方式实现。对于 ASPxTextBox,请使用以下规则为其定义一个
CssClass
属性:我准备了一个小示例来演示它的工作原理。另请参阅 CSS 显示属性。
更新:
当为
ASPxTextBox
指定标题时,它会呈现为表格。这就是为什么建议的方法在这种情况下不起作用。要解决此问题,我建议您将每个文本框放置在 div 元素中,并为其设置“display”属性。The task is not directly related to our controls and can be implemented without them in a similar way. In the case of
ASPxTextBox
, define aCssClass
property to it with the following rule:I've prepared a small sample to demonstrate how it works. See also CSS display Property.
UPDATED:
When a caption is specified for
ASPxTextBox
, it is rendered as a table. That is why the suggested approach does not work in this case. To resolve this issue, I suggest you place each text box in a div element and set the 'display' property for it.