To start with, I have a template setup that came from Microsoft for Timecard Management. This template basically tracks the project someone is working on and the specific task. On one page, it is reading a QueryString Parameter to filter data. I wanted to add a DropDown List to make selecting the projects easier to filter. However, after adding my DropDown List, and selecting the data source, it works, but as soon as I add my code to have it Post Back and set the QueryString Parameter I receive the following error.
"An error occurred during the compilation of the requested file, or one of its dependencies. The name 'DropDownList1' does not exist in the current context
Troubleshoot issues with Microsoft SharePoint Foundation.
Correlation ID: f7afad4b-9af1-43df-8671-8581925f99de"
The Following Code is what I am trying to run:
<script type="text/c#" runat="server">
protected void Page_Load(object sender, EventArgs e)
{
DropDownList1.DataBind();
if(!IsPostBack)
{
if(Request.QueryString["Project"] == (null))
{
Response.Redirect("http://server/test/Lists/Time%20Log/ProjectDetails.aspx?Project=" + DropDownList1.SelectedValue);
}
DropDownList1.SelectedValue = Convert.ToString(Request.QueryString["Project"]);
}
}
protected void SelectionChanged(object sender, EventArgs e)
{
Response.Redirect("http://server/test/Lists/Time%20Log/ProjectDetails.aspx?Project=" + DropDownList1.SelectedValue);
}
</script>
And my DropDownList is declared as the following:
<asp:DropDownList runat="server" id="DropDownList1" AutoPostBack="True" DataValueField="Title" DataTextField="Title" DataSourceID="spdatasource1" OnSelectedIndexChange="SelectionChanged()">
</asp:DropDownList>
I have looked online or a solution, and nothing I have found was the least bit helpful. Scripting is enabled on this page in the web.config files PageParserPaths, and there is not a duplicate Page.aspx in the same directory.
Thanks in advance.