简体   繁体   中英

Textbox placeholder in ASP.NET updatepanel

My problem is that I've set the placeholder for my textbox as follows in an updatepanel in ASP.NET

<asp:TextBox placeholder="First Name" runat="server" ID="txtFirstName"></asp:TextBox>

But, when I try to submit my form, all the placeholder changes to the textbox value. For example, if I send the above textbox empty, it sends with value "First Name"

Try this Code:

<div>
    <asp:ScriptManager runat="server"></asp:ScriptManager>
    <asp:UpdatePanel runat="server" UpdateMode="Always">
        <ContentTemplate>
            <fieldset>
                <asp:TextBox placeholder="First Name" runat="server" ID="txtFirstName"></asp:TextBox>
                <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
                <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
            </fieldset>
        </ContentTemplate>
    </asp:UpdatePanel>
</div>

[OR]

<asp:UpdatePanel runat="server" UpdateMode="Always"></asp:UpdatePanel>
**[AND]**
<asp:TextBox placeholder="First Name" runat="server" ID="txtFirstName" AutoPostBack="true">
</asp:TextBox>

what do you have in the event load of the page

avoids initializing the treatments

try to do:

    protected void Page_Load(object sender, EventArgs e)
    {
        if (! Page.IsPostBack) .....

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