?
Solved

Validation of viewstate MAC failed

Posted on 2007-12-06
4
Medium Priority
?
655 Views
Last Modified: 2012-06-27
This error has just started today, it worked fine as recently as yesterday so I don't know if it was caused by a windows update (last night was weekly server maintenance night which includes updates).
This affects both the production server and my workstation where I develop.

The page loads fine but when I click the edit column on the gridview I get this error:
Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.

After Googling I found this page http://forums.asp.net/p/955145/1173230.aspx#1173230
I have done as suggested there which is to add  enableEventValidation="false" viewStateEncryptionMode ="Never" to the page directive but when I do that I get a new error:
Multiple controls with the same ID 'txtStartDate' were found. FindControl requires that controls have unique IDs.

Which is not the case! There is only one control named that, the only other place it is mentioned is for a validatorcontrol which points to this text box as the control to validate.
0
Comment
Question by:QPR
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 37

Expert Comment

by:samtran0331
ID: 20429133
can you post your gridview?
0
 
LVL 29

Author Comment

by:QPR
ID: 20452366
Below, let me know if you need the rest of the page code.
As I said working fine up until a particular day and then flop!

 <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource3" CellPadding="4" ForeColor="#333333" GridLines="None" Width="672px" AutoGenerateColumns="False" DataKeyNames="NoticeID">
        <Columns>
            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
            <asp:BoundField DataField="NoticeID" HeaderText="NoticeID" InsertVisible="False" ReadOnly="True" SortExpression="NoticeID" Visible="False" />
            <asp:BoundField DataField="NoticeText" HeaderText="Notice" SortExpression="NoticeText" />
            <asp:TemplateField HeaderText="StartDate">
                    <EditItemTemplate>
                        <asp:TextBox ID="txtStartDate" runat="server" Text='<%#Bind("StartDate", "{0:dd/MM/yyyy}") %>' />
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="lblStartDate" runat="server" Text='<%#Eval("StartDate", "{0:dd/MM/yyyy}") %>' />
                    </ItemTemplate>
           </asp:TemplateField>
           <asp:TemplateField HeaderText="StartDate">
                    <EditItemTemplate>
                        <asp:TextBox ID="txtStartDate" runat="server" Text='<%#Bind("ExpiryDate", "{0:dd/MM/yyyy}") %>' />
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="lblStartDate" runat="server" Text='<%#Eval("ExpiryDate", "{0:dd/MM/yyyy}") %>' />
                    </ItemTemplate>
           </asp:TemplateField>
            <asp:BoundField DataField="ExpiryDate" HeaderText="Expiry Date" SortExpression="ExpiryDate" />
        </Columns>
        <FooterStyle BackColor="#5D7B9D" ForeColor="White" Font-Bold="True"></FooterStyle>
        <RowStyle BackColor="#F7F6F3" ForeColor="#333333"></RowStyle>
            <EditRowStyle BackColor="#FFFFC0"></EditRowStyle>
            <SelectedRowStyle BackColor="#E2DED6" ForeColor="#333333" Font-Bold="True"></SelectedRowStyle>
            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center"></PagerStyle>
            <HeaderStyle BackColor="Silver" ForeColor="MidnightBlue" Font-Bold="True"></HeaderStyle>
            <AlternatingRowStyle BackColor="White"></AlternatingRowStyle>
    </asp:GridView>
0
 
LVL 37

Accepted Solution

by:
samtran0331 earned 2000 total points
ID: 20452619
>>I get a new error:
>>Multiple controls with the same ID 'txtStartDate' were found. FindControl requires that controls
>>have unique IDs.

In the above, the StartDate column and the ExpiryDate column both have textboxes named "txtStartDate" in their edititemtemplates....

try:

            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4"
                DataKeyNames="NoticeID" DataSourceID="SqlDataSource3" ForeColor="#333333" GridLines="None"
                Width="672px">
                <Columns>
                    <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
                    <asp:BoundField DataField="NoticeID" HeaderText="NoticeID" InsertVisible="False"
                        ReadOnly="True" SortExpression="NoticeID" Visible="False" />
                    <asp:BoundField DataField="NoticeText" HeaderText="Notice" SortExpression="NoticeText" />
                    <asp:TemplateField HeaderText="StartDate">
                        <EditItemTemplate>
                            <asp:TextBox ID="txtStartDate" runat="server" Text='<%#Bind("StartDate", "{0:dd/MM/yyyy}") %>'>
                            </asp:TextBox>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="lblStartDate" runat="server" Text='<%#Eval("StartDate", "{0:dd/MM/yyyy}") %>'>
                            </asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="ExpiryDate">
                        <EditItemTemplate>
                            <asp:TextBox ID="txtExpiryDate" runat="server" Text='<%#Bind("ExpiryDate", "{0:dd/MM/yyyy}") %>'>
                            </asp:TextBox>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="lblExpiryDate" runat="server" Text='<%#Eval("ExpiryDate", "{0:dd/MM/yyyy}") %>'>
                            </asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
                <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                <EditRowStyle BackColor="#FFFFC0" />
                <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                <HeaderStyle BackColor="Silver" Font-Bold="True" ForeColor="MidnightBlue" />
                <AlternatingRowStyle BackColor="White" />
            </asp:GridView>

Open in new window

0
 
LVL 29

Author Comment

by:QPR
ID: 20452654
well spotted thanks!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question