SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Feb 2012
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Another question about the build your own ASP.NET 4 website

    I have a quick question about this code from chapter 10. I get a warning message in the error window.

    <asp:dataList id="employeesList" runat="server"
    onitemcommand="employeesList_ItemCommand">
    <ItemTemplate>
    <asp:Literal ID="extraDetailsLiteral" runat="server"
    EnableViewState="false" />
    Name: <strong><%#Eval("Name")%></strong><br />
    Username: <strong><%#Eval("Username")%></strong><br />
    <asp:LinkButton ID="detailsButton" runat="server"
    Text=<%#"View more details about " + Eval("Name")%>
    CommandName="MoreDetailsPlease"
    CommandArgument=<%#Eval("EmployeeID")%> />
    <asp:LinkButton ID="editButton" runat="server"
    Text=<%#"Edit employee " + Eval("Name")%>
    CommandName="EditItem"
    CommandArgument=<%#Eval("EmployeeID")%> />
    </ItemTemplate>
    <EditItemTemplate>
    Name: <asp:TextBox ID="nameTextBox" runat="server"
    Text=<%#Eval("Name")%> /><br />
    Username: <asp:TextBox ID="usernameTextBox" runat="server"
    Text=<%#Eval("Username")%> /><br />
    <asp:LinkButton ID="updateButton" runat="server"
    Text="Update Item" CommandName="UpdateItem"
    CommandArgument=<%#Eval("EmployeeID")%> />
    or
    <asp:LinkButton ID="cancelButton" runat="server"
    Text="Cancel Editing" CommandName="CancelEditing"
    CommandArgument=<%#Eval("EmployeeID")%> />
    </EditItemTemplate>

    The code in bold has a green squiggly line under it and I get the following warnings

    “Validation (ASP:NET): Attribute values must be enclosed in quotation marks”

    Now the code works just fine, but is this an example of a work around or non standard approach, or is it just that the debugger does not know how to handle this type of use?

    also the "<asp:dataList id" in this code, the "D" in data is Capitalized but if I use : with a capital D in this post i get for exaple <aspataList id LOL

  2. #2
    SitePoint Member
    Join Date
    Oct 2011
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Coding standards require attributes to be enclosed in quotation marks, that is why VS outputs warnings. Though those warnings are not errors, and the code is workable.

  3. #3
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,629
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    The trick to avoid these is to use different types of quotes -- single quotes are valid in HTML. If you view source of alot of asp.net web forms sites they have all the attributes in single quotes for this reason.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •