有一个DropDownList,一个asp:Linkbutton
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
onselectedindexchanged="DropDownList2_SelectedIndexChanged">
<asp:ListItem Value="1">1</asp:ListItem>
<asp:ListItem Value="2">2</asp:ListItem>
<asp:ListItem Value="3">3</asp:ListItem>
</asp:DropDownList> <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False"
Enabled='<%# DropDownList2.SelectedIndex!=0 %>'>首页</asp:LinkButton>现在想要LinkButton的Enabled用服务器端标记<%# DropDownList2.SelectedIndex!=0 %>来判断,可是老是不能让LinkButton的属性变化,请高手帮忙
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
onselectedindexchanged="DropDownList2_SelectedIndexChanged">
<asp:ListItem Value="1">1</asp:ListItem>
<asp:ListItem Value="2">2</asp:ListItem>
<asp:ListItem Value="3">3</asp:ListItem>
</asp:DropDownList> <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False"
Enabled='<%# DropDownList2.SelectedIndex!=0 %>'>首页</asp:LinkButton>现在想要LinkButton的Enabled用服务器端标记<%# DropDownList2.SelectedIndex!=0 %>来判断,可是老是不能让LinkButton的属性变化,请高手帮忙
或通过onchange设置
<asp:LinkButton ID="btnFirst" runat="server" CausesValidation="False" CommandArgument="First" CommandName="Page" Enabled="<%# ((GridView)Container.NamingContainer).PageIndex != 0 %>" Text="首页"></asp:LinkButton>这样去用DownLoadList控制linkbutton的enable
public bool GetEnable(..
后台
public bool getenable(DropDownList dl)
{
if (dl.SelectedIndex == 0)
return false;
else
return true;
}
前台
<asp:DropDownList ID="DropDownList3" runat="server" AutoPostBack="True">
<asp:ListItem Selected="True">1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
</asp:DropDownList>
<asp:LinkButton ID="LinkButton5" runat="server" Enabled="<%# getenable(DropDownList3)%>">LinkButton</asp:LinkButton>