locked
VS 2013 - asp:TextBox Element Throws Error List Messages for Valid HTML5 Tag Attributes RRS feed

  • Question

  • User1410666720 posted

    I am starting a new HTML5-based ASP.NET Web Application project in Visual Studio 2013, and am having a hard time getting the compiler to recognize valid HTML5 tag attributes within the <asp:TextBox> element. Here is some sample code from a test page:

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="testing_html5.aspx.cs" Inherits="testing_html5" %>
    
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    	<title></title>
    </head>
    <body>
    	<form id="form1" runat="server">
    	<div>
    		<asp:TextBox runat="server" ID="tbxTesting" autocomplete="off" placeholder="Test!"></asp:TextBox>
    
    		<input type="text" autocomplete="off" placeholder="Test!" />
    
    		<textarea placeholder="testing"></textarea>
    
    		<br>
    	</div>
    	</form>
    </body>
    </html>

    And here is the error list that results from this page (I'll replace with an image once I get approved):

    Error List

    You'll notice that the "placeholder" and "autocomplete" attributes appear as invalid attributes for the <asp:TextBox> element, but not for the <input type="text"> elements.

    I have my target schema for validation set to check the doctype of the file, and it is correctly identifying the <!DOCTYPE html> as being HTML5, but for some reason, it doesn't like HTML5 attributes in the <asp:TextBox> element, no matter what I try.

    I realize I can just turn off the messages list, but I would much rather be able to get the <asp:TextBox> element to just recognize the valid attributes.

    Is there any known way of doing this? Thanks so much.

    Tuesday, April 29, 2014 9:21 AM

Answers

  • User1208776063 posted

    I am starting a new HTML5-based ASP.NET Web Application project in Visual Studio 2013, and am having a hard time getting the compiler to recognize valid HTML5 tag attributes within the <asp:TextBox> element

    If you are concerned about the warnings, you can use html input element instead of serverside textbox. You just need to add runat="server" to access value in page event handlers. 

    <input type="text" id="tbxTesting" runat="server" autocomplete="off" placeholder="Test!" />

    As previous member suggested, placeholder and autocomplete are valid attributes that you can use for html elements. As TextBox is a serverside control, Validation schema will be not be able to recognize most of  the the html attributes.  As long as you do not see any warnings about deprecated tags and html formatting errors, you can probably ignore these warnings.  

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 30, 2014 2:10 AM

All replies

  • User-1454326058 posted

    Hi HT Gold,

    That are just the validation messages instead of the error. Also it doesn’t impact the application to combine and run.

    As far as I know, the placeholder attribute is for the html5 elements. (E.g. Input, textarea)

    The asp:TextBox is the server control instead of the html 5 element, although it will be generated to the html elements (Input). So, the placeholder attribute isn’t apply for the asp:TextBox.

    In other words, the placeholder attribute is not useful for asp:TextBox until the asp:TextBox is generated to the input during the runtime.

    So, we couldn’t need to care these messages. It could works fine when we run that application (The browser should be supported HTML 5).

    Thanks

    Best Regards

    Wednesday, April 30, 2014 1:39 AM
  • User1208776063 posted

    I am starting a new HTML5-based ASP.NET Web Application project in Visual Studio 2013, and am having a hard time getting the compiler to recognize valid HTML5 tag attributes within the <asp:TextBox> element

    If you are concerned about the warnings, you can use html input element instead of serverside textbox. You just need to add runat="server" to access value in page event handlers. 

    <input type="text" id="tbxTesting" runat="server" autocomplete="off" placeholder="Test!" />

    As previous member suggested, placeholder and autocomplete are valid attributes that you can use for html elements. As TextBox is a serverside control, Validation schema will be not be able to recognize most of  the the html attributes.  As long as you do not see any warnings about deprecated tags and html formatting errors, you can probably ignore these warnings.  

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 30, 2014 2:10 AM
  • User1410666720 posted

    OK, great, thanks for the answer.

    Although, this is what I was really looking for:

    http://stackoverflow.com/questions/20689890/add-html5-placeholder-text-to-a-textbox-net#20763235

    Wednesday, April 30, 2014 11:36 AM