不知何故,我真的被卡住了,我不知道为什么。我已经阅读了大约3个网站,从谷歌等,但它不会为我工作。
在我的Aspxsite中,我有:
<asp:TableCell>
<asp:UpdatePanel runat="server" UpdateMode="Conditional" ID="UP2">
<%--<Triggers>
<asp:AsyncPostBackTrigger ControlID="ButtonAdd" EventName="Click" />
</Triggers>--%>
<ContentTemplate>
<asp:Button ID="ButtonAdd" runat="server" Text="Add Product" onClick="AddProduct" />
<asp:HiddenField ID="HFAdd" runat="server" Visible="false" />
<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server" BackgroundCssClass="modalBackground"
TargetControlID="ButtonAdd" PopupControlID="PanelChoose" BehaviorID="MPEchoose">
</ajaxToolkit:ModalPopupExtender>
<asp:Panel ID="PanelChoose" runat="server" BorderStyle="Solid" BackColor="ButtonShadow" Visible="false">
<asp:Label ID="Label13" runat="server" Text="Please choose a product!"></asp:Label>
<asp:Table ID="Table3" runat="server">
<asp:TableRow>
<asp:TableCell>
<asp:Button ID="ButtonOK" runat="server" Text="Ok" />
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</asp:TableCell>在后面的代码中:
enter codprotected void AddProduct(object sender, EventArgs e)
{
if (ProductsDDL.SelectedValue.ToString() == "0")
{
Panel1.Visible = true;
ModalPopupExtender1.Show();
}
else
{
ListItem product = new ListItem(ProductsDDL.SelectedItem.ToString(), ProductsDDL.SelectedValue.ToString(), true);
ProductLB.Items.Add(product);
product.Enabled = true;
product.Attributes.CssStyle.Add("Background-Color", LBcolour.Name.ToString());
}
}好吧,我的问题是:
它不会做AddProduct() ...
我已经尝试过了:
使用HFAdd作为TargetControllID,但它也不能在代码背后与.Show()一起工作。然后,如果我没有将PanelChoose visible=设置为“false”,它就会显示在网站上。
因此,我将其设置为false,并尝试在后面的代码中将其设置为true,但随后也不会显示。但是它的工作原理是插入一个带有所选颜色的产品。但是面板没有显示出来。然后还有许多其他的东西,但这里不需要,只要它不能真正工作。
请帮帮我!
发布于 2013-06-18 16:51:55
好的,问题出在UpdatePanel,你需要设置触发器,而我将Panel1s Visiblity设置为false……
因此,删除:
Panel1.Visible = true;
Visible="false"https://stackoverflow.com/questions/16980930
复制相似问题