Site Search:
Sign in | Join | Help
4Penny.net

Steve Gray

Random Thoughts from the 4Penny VP of Development

December 2007 - Posts

  • Unable to validate data

    I'm going to try putting

    <%@ Page Language="vb" EnableViewStateMac="False"%>

    In the page declaration at the top of the page, that seems to be the consensus when I searched on this error.

     

    What is EnableViewStateMac?
    Here is what MSDN documentation has to say about EnableViewStateMac:
     

    EnableViewStateMac
    Indicates that ASP.NET should run a machine authentication check (MAC) on the page's view state when the page is posted back from the client. true if view state should be MAC checked; otherwise, false. The default is false.

    Note   A view state MAC is an encrypted version the hidden variable that a page's view state is persisted to when sent to the browser. When you set this attribute to true, the encrypted view state is checked to verify that it has not been tampered with on the client.

     More info here.

  • Iterating through an XML file

    Given the XML structure:

     <employees>
     <employee>
      <firstname>John</firstname>
      <lastname>Doe</lastname>
     </employee>
     <employee>
      <firstname>James</firstname>
      <lastname>Buck</lastname>
     </employee>
     <employees>
    
    
     

    I sometimes need to loop (iterate) through the file and gather the first/last names

    Here is a piece of code that will do that

                Dim xdoc As New XmlDocument
                xdoc.Load(URL)
    
    
                'get a nodeList filled with employee nodes
                Dim hNodes As XmlNodeList = xdoc.SelectNodes("employees/employee")
                For Each hNode As XmlNode In hNodes
                    'get first and last names, store them
                    strFirstName= hNode.SelectSingleNode("firstname").InnerText
                    strLastName= hNode.SelectSingleNode("lastname").InnerText
    
    
                Next