简体   繁体   中英

why cant i use (id of a textbox).text = "test";

Cannot change text in a asp:TextBox.

I cannot change the text in the asp:TextBox in my onclick function from the code behind.

And I've tried a lot of things (stupid things) but it all didnt work, even other people in the office didnt know what to do.

and now i'm hoping one of you guys know what i need to do.

// .asp.cs file
protected void updateProduct_OnClick(object sender, EventArgs e)
{
    prodName.Text = "test";
}
<table>
                <tr><td>
                        <asp:Label runat="server" Text="Name" />
                    </td><td>
                        <asp:TextBox runat="server" ID="prodName"/>
                </td></tr><tr><td>
                    <asp:Label runat="server" Text="Description" />
                    </td><td>
                        <asp:TextBox runat="server" ID="productDescription" />
                </td></tr><tr><td>
                    <asp:Label runat="server" Text="catagory"/>
                    </td><td>
                        <asp:TextBox runat="server" ID="productCategory"/>
                </td></tr><tr><td>
                    <asp:Label runat="server" Text="price"/>
                </td><td>
                    <asp:TextBox runat="server" ID="productPrice"/>
                </td></tr><tr><td>
                    <asp:LinkButton runat="server" OnClick="OnClick" Text="Add"></asp:LinkButton> |
                    <asp:LinkButton runat="server" OnClick="onSave" Text="save(update)"></asp:LinkButton>
                </td></tr>
            </table>

I've found what the problem whas, it what that it all whas located out of the updatepanel and contenttemplate.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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