質問

Somehow I'm really stuck, I don't know why. I've already read about 3 sites from googling, etc, but it won't work for me.

In my Aspxsite I have:

<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>

And in the code behind:

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());                   
        }     
    }

Well, my problem is:

it won't do AddProduct() ...

What I've already tried:

To use the HFAdd as TargetControllID, but it also didn't work with .Show() in the code behind. Then if I don't set PanelChoose visible="false" then it gets shown in the website.

So I set it to false and tried to set it to true in the code behind, but then it also doesn't get shown. But then it works that it inserts a product with the color that got selected. But the panel doesn't get shown. Then many other things, but not needed here, as far as it didn't work really.

Please help me!

役に立ちましたか?

解決

Okay the problem was the UpdatePanel, you need to set the trigger and that i setted Panel1s Visiblity to false ...

so remove:

Panel1.Visible = true;

Visible="false"
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top