TextBox 不会在单击时传输值 asp.net c#

TextBox doesnt transfer value on singleclick asp.net c#

如果我在文本框中输入内容并点击按钮,文本框的值仍然为空。如果我先点击其他地方(在任何白色 space,就在 textbor 之外)或者如果我点击按钮两次,它就会起作用。

有什么解决办法吗? 我的代码:

  <asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
            <ContentTemplate>
                <asp:Label ID="lblStatus" runat="server" Text="lblStatus"></asp:Label>
                <br />Selektion Typ:
                <br />
                <asp:DropDownList ID="DropDownListLamellentyp" runat="server" onselectedindexchanged="DropDownListLamellentyp_SelectedIndexChanged" 
                                 Visible="True"  Font-Size="Large" AutoPostBack="true" CSSClass="dropDownList">
                </asp:DropDownList>
                <br />
                <br />Selektion Variante:
                <br />
                <asp:DropDownList ID="DropDownListVariant" runat="server" 
                    AutoPostBack="True"
                    onselectedindexchanged="DropDownListVariant_SelectedIndexChanged"  
                    Visible="True" CSSClass="dropDownList" Font-Size="Medium">
                </asp:DropDownList>
                <br />
                <br />
                Fertighöhe eingeben:<br />
                <asp:TextBox ID="txtFertighoehe" runat="server" AutoPostBack="True" 
                    BackColor="#CCFFCC" Font-Bold="True" Font-Size="XX-Large" Height="48px" 
                     Width="190px"></asp:TextBox>
                <asp:Image ID="Image1" runat="server" Height="34px" 
                    ImageUrl="~/pakethoehen1.jpg" Width="69px" />
                <br />
                <br />
                <asp:Button ID="btnCalculate" runat="server" onclick="btnCalculate_Click" 
                 Text="Berechnen" Enabled="False" CSSClass="button" />
                <br />
                <br />
                <asp:Label ID="LabelMessage" runat="server" Text="..." Font-Bold="True" Font-Size="Large"></asp:Label>
            </ContentTemplate>
            </asp:UpdatePanel>

这是因为为文本框控件提供了 AutoPostBack="True",所以如果您从文本框出来,页面会刷新,因此数据会被重置。因此,如果您不想更改文本,请将其删除 event.make 它 false.

<asp:TextBox ID="txtFertighoehe" runat="server" AutoPostBack="false" 
                    BackColor="#CCFFCC" Font-Bold="True" Font-Size="XX-Large" Height="48px" Width="190px"></asp:TextBox>