[英]Is it possible to open <asp:DropDownList> using <asp:LinkButton> on ASP.NET?
我一直在寻找在我的 asp.net 网站上使用我的 <asp:LinkButton <asp:LinkButton>
作为我的<asp:DropDownList>
下拉控件的方法,但搜索结果总是建议通过<"select">
或 < “选项”>。 我的<asp:DropDownList>
没有问题,只是当我在其上应用<CssClass="form-control">
时,它没有显示指示它确实是下拉列表的箭头(我猜未包含在我下载的 css 模板中):
这是我的代码:
<div class="col-md-6 pl-1">
<div class="form-group">
<asp:Label ID="Label4" runat="server" Text="Branch"></asp:Label>
<asp:DropDownList ID="ddlBranch" runat="server" CssClass="form-control">
<asp:ListItem>Calamba</asp:ListItem>
<asp:ListItem>Tanauan</asp:ListItem>
<asp:ListItem>San Pablo</asp:ListItem>
</asp:DropDownList>
</div>
</div>
因此,我在我的另一个<asp:DropDrownList>
上所做的是将它放在<div class="input-group">
和 append 和旁边的<asp:LinkButton>
中:
这是我的代码:
<div class="col-md-5 pr-1">
<asp:Label ID="Label3" runat="server" Text="Account Type"></asp:Label>
<div class="input-group">
<asp:DropDownList ID="ddlAccountType" runat="server" CssClass="form-control" Height="2.7em" OnSelectedIndexChanged="ddlAccountType_SelectedIndexChanged">
<asp:ListItem>Savings</asp:ListItem>
<asp:ListItem>Current</asp:ListItem>
<asp:ListItem>Checking</asp:ListItem>
</asp:DropDownList>
<div class="input-group-append">
<div class="input-group-text">
<asp:LinkButton ID="btnAccountType" runat="server" Font-Underline="False" ForeColor="Black" CssClass="nc-icon nc-minimal-down" />
</div>
</div>
</div>
</div>
但是,当然,当我单击链接按钮时,它只是重新加载页面并且不会打开下拉列表。 我的问题是是否真的有办法将我的<asp:LinkButton>
连接到<asp:DropDownList>
或没有? 提前感谢您回答我的问题!
更新!!!
我不知道这是否可以被视为一个解决方案,但它给了我我想要的结果,所以......我所做的是我使用 <CssClass="accordion"> 因为我下载的 CSS 模板没有有一个样式,并根据我从模板中获得的 <CssClass="form-control"> 为它制作我自己的样式。
在</head>
> 之前的<style>
上的代码(注意:我刚刚从我拥有的模板的.form-control class 复制了它的 css):
<style>
.accordion {
background-color: #FFFFFF;
border: 1px solid #DDDDDD;
border-radius: 4px;
color: #66615b;
line-height: normal;
height: auto;
font-size: 14px;
transition: color 0.3s ease-in-out, border-color 0.3s ease-in-out, background-color 0.3s ease-in-out;
box-shadow: none;
}
.accordion:focus {
border: 1px solid #9A9A9A;
box-shadow: none;
outline: 0 !important;
color: #66615B;
}
</style>
然后我的<asp:DropDownList>
代码如下:
<div class="col-md-5 pr-1">
<asp:Label ID="Label3" runat="server" Text="Account Type"></asp:Label>
<div class="form-group">
<asp:DropDownList ID="ddlAccountType" runat="server" CssClass="accordion" Height="2.68em" Width="100%">
<asp:ListItem>Savings</asp:ListItem>
<asp:ListItem>Current</asp:ListItem>
<asp:ListItem>Checking</asp:ListItem>
</asp:DropDownList>
</div>
</div>
如果我下载的模板上的“.form-control”class 也有下拉列表样式,这无论如何都不是问题。
顺便说一句,对编辑我的问题以使其更形象的人表示敬意。 我实际上是这个平台的新手,所以我仍然不习惯它的某些功能。 非常感谢!
也感谢@John 的链接,我会检查 go。 以防万一我需要它作为未来的参考。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.