Welcome to Tech Support Forum home to more then 136,000 problems solved. Issues have included: Spyware, Malware, Virus Issues, Windows, Microsoft, Linux, Networking, Security, Hardware, and Gaming Getting your problem solved is as easy as:
1. Registering for a free account
2. Asking your question
3. Receiving an answer

Registered members:
* Get free support
* Communicate privately with other members (PM).
* Removal of this message
* See fewer ads.
* And much more..

 



Want to know how to post a question? click here Having problems with spyware and pop-ups? First Steps
Go Back   Tech Support Forum > Design Forum > Web Design & Programming
User Name
Password
Site Map Register Donate Rules Blogs Mark Forums Read


Web Design & Programming Discussion of web design, and server-side & client-side scripting

Reply
 
LinkBack Thread Tools
Old 03-28-2009, 09:23 AM   #1 (permalink)
Registered User
 
Join Date: Mar 2009
Location: Scotland
Posts: 2
OS: XP


Visual Studio 2008

Hey, I'm not sure if this is the right forum but if not I'm sorry.


I'm currently in the middle of developing a catalog based web app for my uni project. A few days ago whilst trying to implement a search feature, I hit some major problems. I've been trying to figure it out, but seen as ASP.net is fairly new to me, I wasn't getting anywhere.

My search box is located in my header user control. The problem I am having is that the codefile for my search page is not picking up the data from the header (least i think this is the problem).

The error I keep getting is:

Quote:
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.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: 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.
I have done this search feature before on a project but I've probably screwed up somewhere along the line.

If anyone could help that would be great :)

Edit// Damn I've just noticed on the main page that theres a web dev forum. Is it possible to move this there?

Last edited by cursedtea; 03-28-2009 at 09:25 AM.
cursedtea is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Important Information
Join the #1 Tech Support Forum Today - It's Totally Free!

TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free.

Join TechSupportforum.com Today - Click Here

Old 03-28-2009, 11:12 AM   #2 (permalink)
Registered User
 
Join Date: Mar 2009
Location: Scotland
Posts: 2
OS: XP


Re: Visual Studio 2008

Sorry for double post, couldnt edit the above post

Here's the code

Search bar in the header.ascx user control:
Code:
<div id="searchdiv">
          <asp:TextBox ID="searchText" Width="350" runat="server" class="input"/>
          <asp:Button ID="searchButton" Text="Search" class="btn" runat="server" PostBackUrl="~/search.aspx" />
        </div>
Search page:
Code:
<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="search.aspx.cs" Inherits="search" %>
<%@ Register TagPrefix="uc" TagName="header" Src="~/header.ascx" %>
<%@ Register TagPrefix="uc" TagName="footer" Src="~/footer.ascx" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Shopaholics.com | Search</title>
    <link href="stylesheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
    <uc:header id="header" runat="server" />
    <div id="location">Location: <a href="home.aspx">Home</a> » <a href="search.aspx">Search</a></div>

    <h1>Search</h1>
        
    <h2>Books » Author</h2>
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
        AllowSorting="True" CellPadding="4" 
        DataSourceID="AccessDataSource1"  DataKeyNames="ID" 
        ForeColor="#c8b0e5" GridLines="None" Width="95%">
        <FooterStyle BackColor="#c8b0e5" Font-Bold="True" ForeColor="White" />
        <RowStyle BackColor="#c8b0e5" ForeColor="#333333" />
        <Columns>
            <asp:BoundField DataField="title" HeaderText="Title" SortExpression="title" />
            <asp:BoundField DataField="author" HeaderText="Author" 
                SortExpression="author" />
            <asp:BoundField DataField="yr_rel" HeaderText="Year Released" 
                SortExpression="yr_rel" />
        </Columns>
        <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
        <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
        <HeaderStyle BackColor="#42206d" Font-Bold="True" ForeColor="White" />
        <AlternatingRowStyle BackColor="White" />
    </asp:GridView>
    
    <asp:AccessDataSource ID="AccessDataSource1" runat="server" 
        DataFile="~/App_Data/Products.mdb" 
        SelectCommand="SELECT [ID], [author], [title], [yr_rel] FROM [books] 
                              WHERE ([author] Like '%' + ? + '%')
                              ORDER BY [author]">
        <SelectParameters>
           <asp:ControlParameter Name="author" 
               ControlID="header:searchText"
               PropertyName="Text" Type="String" DefaultValue="%" />
        </SelectParameters>
    </asp:AccessDataSource>
    


    
    <uc:footer id="footer" runat="server" />
    </form>
</body>
</html>
Finally the search.aspx.cs codefile:
Code:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class search : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        String searchText;
        if (Page.PreviousPage != null)
        {
            Control userControl = PreviousPage.FindControl("header");

            searchText =
              ((TextBox)userControl.FindControl("searchText")).Text;
        }
        else
            if (IsPostBack)
            {
                searchText =
                ((TextBox)FindControl("header").FindControl("searchText")).Text;
            }
            else
            {
                System.Collections.Specialized.NameValueCollection postedValues
                = Request.Form;
                searchText = postedValues["searchText"] ;
            }
        ((TextBox)FindControl("header").FindControl("searchText")).Text =
    searchText;
    }
}
cursedtea is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -7. The time now is 10:54 AM.



Copyright 2001 - 2009, Tech Support Forum
Home Tips Plus | Outdoor Basecamp | Automotive Support Forum

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85