简体   繁体   English

尽管autopostback设置为true,RadioButtonList仍未发布

[英]RadioButtonList not posting back despite autopostback being set to true

I'm having issues trying to get radio button list selected index changes to fire, and although I have no issues with postbacks on any other asp control, radio button lists are giving me trouble. 我在尝试使单选按钮列表选定的索引更改触发时遇到问题,尽管我在其他任何ASP控件上的回发都没有问题,但是单选按钮列表给我带来了麻烦。 I'll include my asp code and c# codebehind in the event one of you may be able to discern what's wrong. 如果你们中的一个人可能会发现问题所在,我将在后面加上我的asp代码和c#代码。

I have 8 radio button lists, all within their own update panels that are set to always update, and each radio button list has autopostback set to true. 我有8个单选按钮列表,它们都在自己的更新面板中设置为始终更新,每个单选按钮列表的autopostback设置为true。

I have code behind logic changing two asp:labels, one changing the average scores based on the radiobuttonlist selections, and one assigning a risk level depending on the value of the average score. 我有逻辑代码来更改两个asp:labels,一个基于单选按钮列表选择更改平均分数,以及一个根据平均分数的值分配风险级别。

<table class="td-table-bordered" style="width: 90%">
                    <tr>
                        <th>
                            <asp:Label ID="CategoryLabel" runat="server" Text="Category"></asp:Label>
                        </th>
                        <th>
                            <asp:Label ID="OccurrenceProbabilityLabel" runat="server" Text="Probability of Occurrence"></asp:Label>
                        </th>
                        <th>
                            <asp:Label ID="ProbabilityRatingLabel" runat="server" Text="Rating"></asp:Label><br />
                            <asp:Label ID="ProbabilityRatingLabel2" runat="server" Text="(L/M/H)"></asp:Label>
                        </th>
                        <th>
                            <asp:Label ID="OccurrenceImpactLabel" runat="server" Text="Impact of Occurrence"></asp:Label>
                        </th>
                        <th>
                            <asp:Label ID="ImpactRatingLabel" runat="server" Text="Rating"></asp:Label><br />
                            <asp:Label ID="ImpactRatingLabel2" runat="server" Text="(L/M/H)"></asp:Label>
                        </th>
                    </tr>
                    <tr>
                        <td>
                            <asp:Label ID="BaseDesktopLabel" runat="server" Text="Base Desktop"></asp:Label>
                        </td>
                        <td>
                            <asp:Label ID="BaseDesktopProbabilityLabel" runat="server" Text="Based on workspace/RBB assessment, what is the probability that this change could impact function, performance or availability of a base component?"></asp:Label>
                        </td>
                        <td>
                            <asp:UpdatePanel ID="DesktopProbabilityPanel" runat="server" UpdateMode="Always">
                                <ContentTemplate>
                                    <asp:RadioButtonList ID="DesktopProbabilityButtonList" runat="server" OnSelectedIndexChanged="DesktopProbabilityButtonList_SelectedIndexChanged" AutoPostBack="True">
                                        <asp:ListItem Text="High" Value="3"></asp:ListItem>
                                        <asp:ListItem Text="Med" Value="2"></asp:ListItem>
                                        <asp:ListItem Text="Low" Value="1"></asp:ListItem>
                                    </asp:RadioButtonList>
                                </ContentTemplate>
                            </asp:UpdatePanel>

                        </td>
                        <td>
                            <asp:Label ID="BaseDesktopImpactLabel" runat="server" Text="If a problem did occur, what could be the extent of the impact to the operation of the workstation?"></asp:Label>
                        </td>
                        <td>
                            <asp:UpdatePanel ID="DesktopImpactPanel" runat="server" UpdateMode="Always">
                                <ContentTemplate>
                                    <asp:RadioButtonList ID="DesktopImpactButtonList" runat="server" OnSelectedIndexChanged="DesktopImpactButtonList_SelectedIndexChanged" AutoPostBack="True">
                                        <asp:ListItem Text="High" Value="3"></asp:ListItem>
                                        <asp:ListItem Text="Med" Value="2"></asp:ListItem>
                                        <asp:ListItem Text="Low" Value="1"></asp:ListItem>
                                    </asp:RadioButtonList>
                                </ContentTemplate>
                            </asp:UpdatePanel>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:Label ID="ProductivityLayerLabel" runat="server" Text="Productivity Layer"></asp:Label>
                        </td>
                        <td>
                            <asp:Label ID="ProductivityLayerProbabilityLabel" runat="server" Text="Based on workspace/RBB engineering assessment, what is the probability that this change could impact function, performance or availability of a productivity application?"></asp:Label>
                        </td>
                        <td>
                            <asp:UpdatePanel ID="ProductivityProbabilityPanel" runat="server" UpdateMode="Always">
                                <ContentTemplate>
                                    <asp:RadioButtonList ID="ProductivityProbabilityButtonList" runat="server" OnSelectedIndexChanged="ProductivityProbabilityButtonList_SelectedIndexChanged" AutoPostBack="True">
                                        <asp:ListItem Text="High" Value="3"></asp:ListItem>
                                        <asp:ListItem Text="Med" Value="2"></asp:ListItem>
                                        <asp:ListItem Text="Low" Value="1"></asp:ListItem>
                                    </asp:RadioButtonList>
                                </ContentTemplate>
                            </asp:UpdatePanel>
                        </td>
                        <td>
                            <asp:Label ID="ProductivityLayerImpactLabel" runat="server" Text="If a problem did occur, what could be the extent of the impact to the operation of the productivity application?"></asp:Label>
                        </td>
                        <td>
                            <asp:UpdatePanel ID="ProductivityImpactPanel" runat="server" UpdateMode="Always">
                                <ContentTemplate>
                                    <asp:RadioButtonList ID="ProductivityImpactButtonList" runat="server" OnSelectedIndexChanged="ProductivityImpactButtonList_SelectedIndexChanged" AutoPostBack="True">
                                        <asp:ListItem Text="High" Value="3"></asp:ListItem>
                                        <asp:ListItem Text="Med" Value="2"></asp:ListItem>
                                        <asp:ListItem Text="Low" Value="1"></asp:ListItem>
                                    </asp:RadioButtonList>
                                </ContentTemplate>
                            </asp:UpdatePanel>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:Label ID="BusinessApplicationsLabel" runat="server" Text="Business Applications"></asp:Label>
                        </td>
                        <td>
                            <asp:Label ID="BusinessApplicationsProbabilityLabel" runat="server" Text="Based on workspace engineering assessment, what is the probability that this change could impact function, performance or availability of a business application?"></asp:Label>
                        </td>
                        <td>
                            <asp:UpdatePanel ID="BusinessProbabilityPanel" runat="server" UpdateMode="Always">
                                <ContentTemplate>
                                    <asp:RadioButtonList ID="BusinessProbabilityButtonList" runat="server" OnSelectedIndexChanged="BusinessProbabilityButtonList_SelectedIndexChanged" AutoPostBack="True">
                                        <asp:ListItem Text="High" Value="3"></asp:ListItem>
                                        <asp:ListItem Text="Med" Value="2"></asp:ListItem>
                                        <asp:ListItem Text="Low" Value="1"></asp:ListItem>
                                    </asp:RadioButtonList>
                                </ContentTemplate>
                            </asp:UpdatePanel>
                        </td>
                        <td>
                            <asp:Label ID="BusinessApplicationsImpactLabel" runat="server" Text="If a problem did occur, what could be the extent of the impact to the operation of the business application?"></asp:Label>
                        </td>
                        <td>
                            <asp:UpdatePanel ID="BusinessImpactPanel" runat="server" UpdateMode="Always">
                                <ContentTemplate>
                                    <asp:RadioButtonList ID="BusinessImpactButtonList" runat="server" OnSelectedIndexChanged="BusinessImpactButtonList_SelectedIndexChanged" AutoPostBack="True">
                                        <asp:ListItem Text="High" Value="3"></asp:ListItem>
                                        <asp:ListItem Text="Med" Value="2"></asp:ListItem>
                                        <asp:ListItem Text="Low" Value="1"></asp:ListItem>
                                    </asp:RadioButtonList>
                                </ContentTemplate>
                            </asp:UpdatePanel>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:Label ID="DatacenterLabel" runat="server" Text="Datacenter/Infrastructure"></asp:Label>
                        </td>
                        <td>
                            <asp:Label ID="DatacenterProbabilityLabel" runat="server" Text="What is the probability that this change could impact function, performance or availability of networks, infrastructure or web services used by the branch??"></asp:Label>
                        </td>
                        <td>
                            <asp:UpdatePanel ID="DatacenterProbabilityPanel" runat="server" UpdateMode="Always">
                                <ContentTemplate>
                                    <asp:RadioButtonList ID="DatacenterProbabilityButtonList" runat="server" OnSelectedIndexChanged="DatacenterProbabilityButtonList_SelectedIndexChanged" AutoPostBack="True">
                                        <asp:ListItem Text="High" Value="3"></asp:ListItem>
                                        <asp:ListItem Text="Med" Value="2"></asp:ListItem>
                                        <asp:ListItem Text="Low" Value="1"></asp:ListItem>
                                    </asp:RadioButtonList>
                                </ContentTemplate>
                            </asp:UpdatePanel>
                        </td>
                        <td>
                            <asp:Label ID="DataCenterImpactLabel" runat="server" Text="If a problem did occur, what could be the extent of the impact to the operation of the datacenter or infrastructure?"></asp:Label>
                        </td>
                        <td>
                            <asp:UpdatePanel ID="DataCenterImpactPanel" runat="server" UpdateMode="Always">
                                <ContentTemplate>
                                    <asp:RadioButtonList ID="DatacenterImpactButtonList" runat="server" OnSelectedIndexChanged="DatacenterImpactList_SelectedIndexChanged" AutoPostBack="True">
                                        <asp:ListItem Text="High" Value="3"></asp:ListItem>
                                        <asp:ListItem Text="Med" Value="2"></asp:ListItem>
                                        <asp:ListItem Text="Low" Value="1"></asp:ListItem>
                                    </asp:RadioButtonList>
                                </ContentTemplate>
                            </asp:UpdatePanel>
                        </td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                        <td style="text-align: right">
                            <asp:Label ID="OverAllRatingLabel" runat="server" Font-Bold="True" Text="Change Risks Overall Average Rating: "></asp:Label>
                        </td>
                        <td style="text-align: right">
                            <asp:Label ID="OverallRating" runat="server" Font-Bold="True"></asp:Label>
                        </td>
                        <td style="text-align: right">
                            <asp:Label ID="OverallRiskLabel" runat="server" Font-Bold="True" Text="Overall Risk: "></asp:Label>
                        </td>
                        <td style="text-align: right">
                            <asp:Label ID="OverallRisk" runat="server" Font-Bold="True"></asp:Label>
                        </td>
                    </tr>
                </table>

And now my c# 现在我的C#

double averageRating, desktopProbabilityRating, desktopImpactRating, productivityProbabilityRating, productivityImpactRating, businessProbabilityRating, businessImpactRating, datacenterProbabilityRating, datacenterImpactRating = 0;

protected void DesktopProbabilityButtonList_SelectedIndexChanged(object sender, EventArgs e) {
    desktopProbabilityRating = Convert.ToDouble(DesktopProbabilityButtonList.SelectedValue);
    calculateAverage();   
}

protected void DesktopImpactButtonList_SelectedIndexChanged(object sender, EventArgs e) {
    desktopImpactRating = Convert.ToDouble(DesktopImpactButtonList.SelectedValue);
    calculateAverage();
}

protected void ProductivityProbabilityButtonList_SelectedIndexChanged(object sender, EventArgs e) {
    productivityProbabilityRating = Convert.ToDouble(ProductivityProbabilityButtonList.SelectedValue);
    calculateAverage();
}

protected void ProductivityImpactButtonList_SelectedIndexChanged(object sender, EventArgs e) {
    productivityImpactRating = Convert.ToDouble(ProductivityImpactButtonList.SelectedValue);
    calculateAverage();
}

protected void BusinessProbabilityButtonList_SelectedIndexChanged(object sender, EventArgs e) {
    businessProbabilityRating = Convert.ToDouble(BusinessProbabilityButtonList.SelectedValue);
    calculateAverage();
}

protected void BusinessImpactButtonList_SelectedIndexChanged(object sender, EventArgs e) {
    businessImpactRating = Convert.ToDouble(BusinessImpactButtonList.SelectedValue);
    calculateAverage();
}

protected void DatacenterProbabilityButtonList_SelectedIndexChanged(object sender, EventArgs e) {
    datacenterProbabilityRating = Convert.ToDouble(DatacenterProbabilityButtonList.SelectedValue);
    calculateAverage();
}

protected void DatacenterImpactList_SelectedIndexChanged(object sender, EventArgs e) {
    datacenterImpactRating = Convert.ToDouble(DatacenterImpactButtonList.SelectedValue);
    calculateAverage();
}

protected void calculateAverage() {
    averageRating = (desktopProbabilityRating + desktopImpactRating + productivityProbabilityRating + productivityImpactRating + businessProbabilityRating + businessImpactRating + datacenterProbabilityRating + datacenterImpactRating) / 8;
    OverallRating.Text = averageRating.ToString();
    if(averageRating <= 1) {
        OverallRisk.Text = "Low";
    }
    else if(averageRating > 1 && averageRating < 3) {
        OverallRisk.Text = "Med";
    }
    else if(averageRating >=3 || desktopProbabilityRating == 3 || desktopImpactRating == 3 || productivityProbabilityRating == 3 || productivityImpactRating == 3 || businessProbabilityRating == 3 || businessImpactRating == 3 || datacenterProbabilityRating == 3 || datacenterImpactRating == 3) {
        OverallRisk.Text = "High";
    }
}

This SHOULD be posting back, I absolutely can't determine why every other control on my form posts back just fine and not these. 这应该发回,我绝对不能确定为什么表单上的所有其他控件都发回正常,而不是这些。 Would someone be able to help determine why? 有人可以帮助确定原因吗? No other question on stack overflow concerning this applied to my problem. 关于此的堆栈溢出问题没有其他问题适用于我的问题。

Thanks so much in advance. 非常感谢。

Your labels are outside the update panels, that is why it is not working. 您的标签在更新面板之外,这就是为什么它不起作用的原因。 All the radio buttons postback without any issue. 所有单选按钮都回发,没有任何问题。

I would suggest you to wrap all the controls inside one update panel. 我建议您将所有控件包装在一个更新面板中。

Please read further here https://forums.asp.net/t/1120428.aspx?Update+Label+outside+update+panel 请在这里进一步阅读https://forums.asp.net/t/1120428.aspx?Update+Label+outside+update+panel

<asp:UpdatePanel ID="updatePanel" runat="server" UpdateMode="Always">
                            <ContentTemplate>
<table class="td-table-bordered" style="width: 90%">
                <tr>
                    <th>
                        <asp:Label ID="CategoryLabel" runat="server" Text="Category"></asp:Label>
                    </th>
                    <th>
                        <asp:Label ID="OccurrenceProbabilityLabel" runat="server" Text="Probability of Occurrence"></asp:Label>
                    </th>
                    <th>
                        <asp:Label ID="ProbabilityRatingLabel" runat="server" Text="Rating"></asp:Label><br />
                        <asp:Label ID="ProbabilityRatingLabel2" runat="server" Text="(L/M/H)"></asp:Label>
                    </th>
                    <th>
                        <asp:Label ID="OccurrenceImpactLabel" runat="server" Text="Impact of Occurrence"></asp:Label>
                    </th>
                    <th>
                        <asp:Label ID="ImpactRatingLabel" runat="server" Text="Rating"></asp:Label><br />
                        <asp:Label ID="ImpactRatingLabel2" runat="server" Text="(L/M/H)"></asp:Label>
                    </th>
                </tr>
                <tr>
                    <td>
                        <asp:Label ID="BaseDesktopLabel" runat="server" Text="Base Desktop"></asp:Label>
                    </td>
                    <td>
                        <asp:Label ID="BaseDesktopProbabilityLabel" runat="server" Text="Based on workspace/RBB assessment, what is the probability that this change could impact function, performance or availability of a base component?"></asp:Label>
                    </td>
                    <td>

                                <asp:RadioButtonList ID="DesktopProbabilityButtonList" runat="server" OnSelectedIndexChanged="DesktopProbabilityButtonList_SelectedIndexChanged" AutoPostBack="True">
                                    <asp:ListItem Text="High" Value="3"></asp:ListItem>
                                    <asp:ListItem Text="Med" Value="2"></asp:ListItem>
                                    <asp:ListItem Text="Low" Value="1"></asp:ListItem>
                                </asp:RadioButtonList>


                    </td>
                    <td>
                        <asp:Label ID="BaseDesktopImpactLabel" runat="server" Text="If a problem did occur, what could be the extent of the impact to the operation of the workstation?"></asp:Label>
                    </td>
                    <td>
                              <asp:RadioButtonList ID="DesktopImpactButtonList" runat="server" OnSelectedIndexChanged="DesktopImpactButtonList_SelectedIndexChanged" AutoPostBack="True">
                                    <asp:ListItem Text="High" Value="3"></asp:ListItem>
                                    <asp:ListItem Text="Med" Value="2"></asp:ListItem>
                                    <asp:ListItem Text="Low" Value="1"></asp:ListItem>
                                </asp:RadioButtonList>

                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Label ID="ProductivityLayerLabel" runat="server" Text="Productivity Layer"></asp:Label>
                    </td>
                    <td>
                        <asp:Label ID="ProductivityLayerProbabilityLabel" runat="server" Text="Based on workspace/RBB engineering assessment, what is the probability that this change could impact function, performance or availability of a productivity application?"></asp:Label>
                    </td>
                    <td>

                                <asp:RadioButtonList ID="ProductivityProbabilityButtonList" runat="server" OnSelectedIndexChanged="ProductivityProbabilityButtonList_SelectedIndexChanged" AutoPostBack="True">
                                    <asp:ListItem Text="High" Value="3"></asp:ListItem>
                                    <asp:ListItem Text="Med" Value="2"></asp:ListItem>
                                    <asp:ListItem Text="Low" Value="1"></asp:ListItem>
                                </asp:RadioButtonList>

                    </td>
                    <td>
                        <asp:Label ID="ProductivityLayerImpactLabel" runat="server" Text="If a problem did occur, what could be the extent of the impact to the operation of the productivity application?"></asp:Label>
                    </td>
                    <td>
                              <asp:RadioButtonList ID="ProductivityImpactButtonList" runat="server" OnSelectedIndexChanged="ProductivityImpactButtonList_SelectedIndexChanged" AutoPostBack="True">
                                    <asp:ListItem Text="High" Value="3"></asp:ListItem>
                                    <asp:ListItem Text="Med" Value="2"></asp:ListItem>
                                    <asp:ListItem Text="Low" Value="1"></asp:ListItem>
                                </asp:RadioButtonList>

                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Label ID="BusinessApplicationsLabel" runat="server" Text="Business Applications"></asp:Label>
                    </td>
                    <td>
                        <asp:Label ID="BusinessApplicationsProbabilityLabel" runat="server" Text="Based on workspace engineering assessment, what is the probability that this change could impact function, performance or availability of a business application?"></asp:Label>
                    </td>
                    <td>
                               <asp:RadioButtonList ID="BusinessProbabilityButtonList" runat="server" OnSelectedIndexChanged="BusinessProbabilityButtonList_SelectedIndexChanged" AutoPostBack="True">
                                    <asp:ListItem Text="High" Value="3"></asp:ListItem>
                                    <asp:ListItem Text="Med" Value="2"></asp:ListItem>
                                    <asp:ListItem Text="Low" Value="1"></asp:ListItem>
                                </asp:RadioButtonList>

                    </td>
                    <td>
                        <asp:Label ID="BusinessApplicationsImpactLabel" runat="server" Text="If a problem did occur, what could be the extent of the impact to the operation of the business application?"></asp:Label>
                    </td>
                    <td>
                              <asp:RadioButtonList ID="BusinessImpactButtonList" runat="server" OnSelectedIndexChanged="BusinessImpactButtonList_SelectedIndexChanged" AutoPostBack="True">
                                    <asp:ListItem Text="High" Value="3"></asp:ListItem>
                                    <asp:ListItem Text="Med" Value="2"></asp:ListItem>
                                    <asp:ListItem Text="Low" Value="1"></asp:ListItem>
                                </asp:RadioButtonList>

                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Label ID="DatacenterLabel" runat="server" Text="Datacenter/Infrastructure"></asp:Label>
                    </td>
                    <td>
                        <asp:Label ID="DatacenterProbabilityLabel" runat="server" Text="What is the probability that this change could impact function, performance or availability of networks, infrastructure or web services used by the branch??"></asp:Label>
                    </td>
                    <td>
                               <asp:RadioButtonList ID="DatacenterProbabilityButtonList" runat="server" OnSelectedIndexChanged="DatacenterProbabilityButtonList_SelectedIndexChanged" AutoPostBack="True">
                                    <asp:ListItem Text="High" Value="3"></asp:ListItem>
                                    <asp:ListItem Text="Med" Value="2"></asp:ListItem>
                                    <asp:ListItem Text="Low" Value="1"></asp:ListItem>
                                </asp:RadioButtonList>

                    </td>
                    <td>
                        <asp:Label ID="DataCenterImpactLabel" runat="server" Text="If a problem did occur, what could be the extent of the impact to the operation of the datacenter or infrastructure?"></asp:Label>
                    </td>
                    <td>
                         <asp:RadioButtonList ID="DatacenterImpactButtonList" runat="server" OnSelectedIndexChanged="DatacenterImpactList_SelectedIndexChanged" AutoPostBack="True">
                                    <asp:ListItem Text="High" Value="3"></asp:ListItem>
                                    <asp:ListItem Text="Med" Value="2"></asp:ListItem>
                                    <asp:ListItem Text="Low" Value="1"></asp:ListItem>
                                </asp:RadioButtonList>

                    </td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                    <td style="text-align: right">
                        <asp:Label ID="OverAllRatingLabel" runat="server" Font-Bold="True" Text="Change Risks Overall Average Rating: "></asp:Label>
                    </td>
                    <td style="text-align: right">
                        <asp:Label ID="OverallRating" runat="server" Font-Bold="True"></asp:Label>
                    </td>
                    <td style="text-align: right">
                        <asp:Label ID="OverallRiskLabel" runat="server" Font-Bold="True" Text="Overall Risk: "></asp:Label>
                    </td>
                    <td style="text-align: right">
                        <asp:Label ID="OverallRisk" runat="server" Font-Bold="True"></asp:Label>
                    </td>
                </tr>
            </table>
                                </ContentTemplate>
                        </asp:UpdatePanel>

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

相关问题 RadioButtonList设置为AutoPostBack = true,但仍不触发OnSelectedIndexChanged - RadioButtonList set to AutoPostBack = true but still not firing OnSelectedIndexChanged 即使设置了AutoPostBack,DropDownList也不会回发 - DropDownList not posting back, even with AutoPostBack set 尽管autopostback为true,Asp.net OnSelectedIndexChanged事件未触发 - Asp.net OnSelectedIndexChanged event not firing despite autopostback being true 当RadioButtonList选择asp.net C#时,SelectedIndexChanged无法正常工作? autopostback还设置为true吗? - SelectedIndexChanged not working while RadioButtonList selected asp.net c#? autopostback also set to true? 在Telerik Radcalander中将AutoPostBack设置为True的onclient - getting onclient with AutoPostBack set to True in telerik radcalander 将DropDown的SelectedIndex设置为0,并将AutoPostBack设置为true - Setting SelectedIndex to 0 for DropDown with AutoPostBack set to true DropDownList 事件未在 AutoPostBack 设置为 true 时触发 - DropDownList event not firing with AutoPostBack set to true 在updatepanel中将AutoPostBack设置为true的DropdownList验证 - DropdownList validation with AutoPostBack set to true inside updatepanel RadioButtonList选择在AutoPostBack上无法正常工作 - RadioButtonList selection not working properly on AutoPostBack 自动回发功能后将焦点设置回正确的文本框 - Set focus back to the proper textbox after autopostback function
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM