簡體   English   中英

盡管autopostback設置為true,RadioButtonList仍未發布

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

我在嘗試使單選按鈕列表選定的索引更改觸發時遇到問題,盡管我在其他任何ASP控件上的回發都沒有問題,但是單選按鈕列表給我帶來了麻煩。 如果你們中的一個人可能會發現問題所在,我將在后面加上我的asp代碼和c#代碼。

我有8個單選按鈕列表,它們都在自己的更新面板中設置為始終更新,每個單選按鈕列表的autopostback設置為true。

我有邏輯代碼來更改兩個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>

現在我的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";
    }
}

這應該發回,我絕對不能確定為什么表單上的所有其他控件都發回正常,而不是這些。 有人可以幫助確定原因嗎? 關於此的堆棧溢出問題沒有其他問題適用於我的問題。

非常感謝。

您的標簽在更新面板之外,這就是為什么它不起作用的原因。 所有單選按鈕都回發,沒有任何問題。

我建議您將所有控件包裝在一個更新面板中。

請在這里進一步閱讀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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM