【问题标题】:Textbox placeholder in ASP.NET updatepanelASP.NET 更新面板中的文本框占位符
【发布时间】:2017-08-07 16:53:00
【问题描述】:

我的问题是我在 ASP.NET 的 updatepanel 中为我的文本框设置了如下占位符

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

但是,当我尝试提交表单时,所有占位符都会更改为文本框的值。例如,如果我将上面的文本框发送为空,它会发送值“First Name”

【问题讨论】:

    标签: html asp.net ajax updatepanel


    【解决方案1】:

    试试这个代码:

    <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>
    

    [或]

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

    【讨论】:

    • 我发现这个问题和Javascript有关
    【解决方案2】:

    页面的事件加载你有什么

    避免初始化治疗

    尝试做:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-12-01
      • 2014-08-19
      • 2020-05-27
      • 1970-01-01
      • 2018-11-24
      • 2018-01-28
      • 1970-01-01
      相关资源
      最近更新 更多