我只想根据 asp.net 网站的 ComboBox 中的选定索引更改我的面板背景图像。但是图像没有加载。这是我在 .aspx 页面中的代码
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true"
onselectedindexchanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
</asp:DropDownList>
<div id="divx" style="height: 250px">
<asp:Panel ID="Panel1" runat="server" Height="242px">
</asp:Panel>
</div>
这是背后的代码..
protected void Page_Load(object sender, EventArgs e)
{ }
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (DropDownList1.SelectedIndex == 1)
{
Panel1.BackImageUrl="C:\\Users\\Laksh\\Documents\\Visual Studio 2010\\WebSites\\WebSite2\\Pic\\Capture.JPG";
}
else if (DropDownList1.SelectedIndex == 2)
{
Panel1.BackImageUrl="C:\\Users\\Laksh\\Documents\\Visual Studio 2010\\WebSites\\WebSite2\\Pic\\erroe.JPG";
}
}