Search code examples
asp.nettwitter-bootstrapmaterialize

ASP Textbox control placeholder property doesn't work in Internet Explorer


I'm using the framework of Materialize from materializecss.com. The placeholder for the textbox isn't working on IE, I think the framework has something to do with this because from my other page I tried using bootstrap framework, and the placeholder property worked, is there any solution for me to make the placeholder property work on the Materialize framework?

<div class="row">
  <div class="input-field col s10">
     <asp:TextBox ID="txtCompany" runat="server" Visible="false" placeholder="Company Name" ></asp:TextBox>                  
   </div>
  <div class="input-field col s2">
     <asp:Button ID="btnSave" runat="server" Text="Save" CssClass="btn waves-effect waves-red" OnClick="btnSave_Click" Visible="false" />
  </div>
</div>

Solution

  • You need to add onfocus and onblur property in your textbox for working it in Internet Explorer

    Here you go

    <div class="input-field col s10">
        <asp:TextBox ID="txtCompany" runat="server" value="Company Name" placeholder="Company Name" onfocus="if(this.value==this.defaultValue)this.value='';" onblur="if(this.value=='')this.value=this.defaultValue;"></asp:TextBox>
    </div>