简体   繁体   English

ASP.NET事件未触发

[英]ASP.NET Event not firing

So I have event that basically checks if I have already added to shipment already. 所以我有一个事件,它基本上检查我是否已经添加到发货中。 I put a break point in at inventoryBLL inv = new inventoryBLL(); 我在inventoryBLL inv = new inventoryBLL();设置了一个断点inventoryBLL inv = new inventoryBLL(); and it never breaks. 它永远不会中断。 The funny thing is that I can get the index without much fuss. 有趣的是,我可以毫不费力地获取索引。

My C# 我的C#

    protected void rblSwitch1_SelectedIndexChanged(object sender, EventArgs e)
    {

        inventoryBLL inv = new inventoryBLL();
        List<string> asinholder = new List<string>();
        List<string> fnskuholder = new List<string>();


        int Index = new int();
        asinwrapper asin = asinwrapper.GetSessionWrapper();
        if (asin != null)
        {
            fnskuholder = asin.FNSKU;
            asinholder = asin.ASIN;
            Index = asin.Index;

        }
        List<shipmentdetail> detail = new List<shipmentdetail>();
        multipleshipments m = multipleshipments.GetSessionWrapper();
        if (m != null)
        {
            detail = m.Detail;
        }
        inventory.ItemCheckDataTable items = inv.GetItem(asinholder[Index], detail[0].Id[ddlExisting1.SelectedIndex]);
        if (items.Rows.Count < 0)
        {
            foreach (inventory.ItemCheckRow row in items)
            {
                txt.Text = row.Quantity;
            }
        }
    }

This is the HTML 这是HTML

                <asp:RadioButtonList ID="rblSwitch1" runat="server" 
                    onselectedindexchanged="rblSwitch1_SelectedIndexChanged">
                    <asp:ListItem Value="0">New Shipment</asp:ListItem>
                    <asp:ListItem Value="1">Existing Shipment</asp:ListItem>
                </asp:RadioButtonList>

Add AutoPostBack = "true" to your tag. AutoPostBack = "true"添加到您的标签。 This should be it: 应该是这样:

<asp:RadioButtonList ID="rblSwitch1" runat="server" AutoPostBack="true" 
  onselectedindexchanged="rblSwitch1_SelectedIndexChanged"> 
 <asp:ListItem Value="0">New Shipment</asp:ListItem> 
 <asp:ListItem Value="1">Existing Shipment</asp:ListItem> 
</asp:RadioButtonList> 

Here is a decent reference showing an example. 这是显示示例的体面参考。

If it's not caused by AutoPostBack of the control being set to false, check if AutoEventWireup is set false. 如果不是由控件的AutoPostBack设置为false引起的,请检查AutoEventWireup是否设置为false。 It can be set in several places, including page header and config files. 可以在多个位置进行设置,包括页面标题和配置文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM