![]() |
![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
|||
| 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: * 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 |
|
|||||||
| Web Design & Programming Discussion of web design, and server-side & client-side scripting |
![]() |
|
|
LinkBack | Thread Tools |
|
|
#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:
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. |
|
|
|
|
| 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 |
|
|
#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>
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>
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;
}
}
|
|
|
|
![]() |
| Thread Tools | |
|
|