我有一个由其他人建造的网络工具。应用程序根据最终用户输入的搜索参数查询数据库,例如“部件号,部件状态等”。当用户点击搜索页面时,它们会显示一个简单的文本框以输入部件号,以及一个使用JavaScript切换show all parameters功能的按钮。如果用户使用一组参数进行搜索,则会显示部件列表。如果用户点击某个零件,他们将被带到零件描述页面。
困境:当用户点击零件描述页面然后调用后退按钮时,它们将显示第一个初始搜索页面,而不是返回到零件列表。我希望将它们带回到部件列表中,而不是重置表单。
请参阅下面的代码示例(非常感谢任何帮助):
ASPX Page:
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="AdvancedSearch.aspx.cs" Inherits="AdvancedSearch" %>
<%@ MasterType VirtualPath="~/MasterPage.master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1" ClientEvents-OnRequestStart="RadAjaxManager1_OnRequestStart">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="MainContainer">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="MainContainer" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel runat="server" ID="RadAjaxLoadingPanel1" IsSticky="true" Style="position: absolute; top: 0; left: 0; height: 100%; width: 100%;" />
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script language="javascript" type="text/javascript">
function RadAjaxManager1_OnRequestStart(ajaxManager, eventArgs) {
try {
var re = new RegExp("\.DataDump$", "ig");
if (eventArgs.EventTarget.match(re)) {
eventArgs.EnableAjax = false;
}
}
catch (err) {
alert("RadAjaxManager1_OnRequestStart(...) " + err);
}
}
function ToggleSearchOptions(sender, args) {
if (sender.get_text() == "Show Search Options") {
sender.set_text("Hide Search Options");
document.getElementById('<%= Search_Options_Container.ClientID %>').style.display = "";
}
else {
sender.set_text("Show Search Options");
document.getElementById('<%= Search_Options_Container.ClientID %>').style.display = "none";
}
sender.set_autoPostBack(false);
}
function ToggleEquipment(state) {
giTools.CheckUnCheckList('<%= Equipment_Fields.ClientID %>', state);
giTools.CheckUnCheckList('<%= Equipment_Type.ClientID %>', state);
giTools.CheckUnCheckList('<%= Equipment_Status.ClientID %>', state);
if (state == true) {
$('#<%= Equipment_Type_All.ClientID %>').attr('checked', 'checked');
$('#<%= Equipment_Status_All.ClientID %>').attr('checked', 'checked');
}
else {
$('#<%= Equipment_Type_All.ClientID %>').removeAttr("checked");
$('#<%= Equipment_Status_All.ClientID %>').removeAttr("checked");
}
}
function ToggleEquipment_Type(state) {
giTools.CheckUnCheckList('<%= Equipment_Type.ClientID %>', state);
}
function ToggleEquipment_Status(state) {
giTools.CheckUnCheckList('<%= Equipment_Status.ClientID %>', state);
}
function ToggleHistory(state) {
giTools.CheckUnCheckList('<%= History_Fields.ClientID %>', state);
giTools.CheckUnCheckList('<%= History_Status.ClientID %>', state);
if (state == true) {
$('#<%= History_Status_All.ClientID %>').attr('checked', 'checked');
}
else {
$('#<%= History_Status_All.ClientID %>').removeAttr("checked");
}
}
function ToggleHistory_Status(state) {
giTools.CheckUnCheckList('<%= History_Status.ClientID %>', state);
}
function ToggleOTR(state) {
giTools.CheckUnCheckList('<%= OTR_Fields.ClientID %>', state);
giTools.CheckUnCheckList('<%= OTR_Classification.ClientID %>', state);
if (state == true) {
$('#<%= OTR_Classification_All.ClientID %>').attr('checked', 'checked');
}
else {
$('#<%= OTR_Classification_All.ClientID %>').removeAttr("checked");
}
}
function ToggleOTR_Classification(state) {
giTools.CheckUnCheckList('<%= OTR_Classification.ClientID %>', state);
}
function ToggleDates(value) {
$find('<%= Date_Start.ClientID %>').set_enabled(value);
$find('<%= Date_End.ClientID %>').set_enabled(value);
}
</script>
</telerik:RadCodeBlock>
<div id="MainContainer" runat="server">
<asp:Panel ID="Panel1" runat="server" DefaultButton="Submit">
<table class="custom_table custom_border" cellpadding="0" cellspacing="0">
<tr>
<td>Terms to Search for
</td>
<td>
<telerik:RadTextBox ID="SearchValue" runat="server" />
</td>
<td>
<telerik:RadButton ID="Submit" runat="server" Text="Search" OnClick="Submit_Click" />
</td>
<td style="text-align: center;">
<telerik:RadButton ID="ShowHideSearchOptions" runat="server" Text="Show Search Options" ButtonType="LinkButton" OnClientClicking="ToggleSearchOptions"
Width="120" />
</td>
</tr>
</table>
</asp:Panel>
<div id="Search_Options_Container" runat="server" style="display: none;">
<br />
<div class="clearfix">
<div style="float: left;">
<table class="custom_table custom_border" cellpadding="0" cellspacing="0" width="210">
<tr>
<td class="custom_border_bottom" style="padding-left: 6px; padding-right: 5px;">
<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<td>
<strong>Search Equipment</strong>
</td>
<td style="text-align: right;">
<strong>
<asp:CheckBox ID="Equipment_All" runat="server" Text="All" Checked="true" onclick="ToggleEquipment(this.checked)" /></strong>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="custom_border_bottom">
<asp:CheckBoxList ID="Equipment_Fields" runat="server">
<asp:ListItem Text="TMS #" Selected="True" />
<asp:ListItem Text="Assigned To" Selected="True" />
<asp:ListItem Text="Issued To" Selected="True" />
<asp:ListItem Text="Department" Selected="True" />
<asp:ListItem Text="Manufacturer" Selected="True" />
<asp:ListItem Text="Model #" Selected="True" />
<asp:ListItem Text="Serial #" Selected="True" />
<asp:ListItem Text="Description" Selected="True" />
<asp:ListItem Text="Characteristics" Selected="True" />
<asp:ListItem Text="Calibration Procedure" Selected="True" />
<asp:ListItem Text="Calibration Standard" Selected="True" />
<asp:ListItem Text="Calibration Interval" Selected="True" />
<asp:ListItem Text="Required Accuracy" Selected="True" />
</asp:CheckBoxList>
</td>
</tr>
<tr>
<td class="custom_border_bottom">
<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<td>
<strong>Type</strong>
</td>
<td style="text-align: right;">
<strong>
<asp:CheckBox ID="Equipment_Type_All" runat="server" Text="All" Checked="true" onclick="ToggleEquipment_Type(this.checked)" /></strong>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="custom_border_bottom">
<asp:CheckBoxList ID="Equipment_Type" runat="server">
<asp:ListItem Text="Electronic" Value="1" Selected="True" />
<asp:ListItem Text="Mechanical" Value="2" Selected="True" />
</asp:CheckBoxList>
</td>
</tr>
<tr>
<td class="custom_border_bottom">
<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<td>
<strong>Status</strong>
</td>
<td style="text-align: right;">
<strong>
<asp:CheckBox ID="Equipment_Status_All" runat="server" Text="All" Checked="true" onclick="ToggleEquipment_Status(this.checked)" /></strong>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="custom_border_bottom">
<asp:CheckBoxList ID="Equipment_Status" runat="server">
<asp:ListItem Text="Active" Value="1" Selected="True" />
<asp:ListItem Text="NCR" Value="2" Selected="True" />
<asp:ListItem Text="CBU" Value="3" Selected="True" />
<asp:ListItem Text="TOS" Value="4" Selected="True" />
<asp:ListItem Text="Missing" Value="5" Selected="True" />
<asp:ListItem Text="Stock" Value="6" Selected="True" />
<asp:ListItem Text="Extended" Value="7" Selected="True" />
</asp:CheckBoxList>
</td>
</tr>
<tr>
<td>
<asp:CheckBoxList ID="Equipment_Status_Obsolete" runat="server">
<asp:ListItem Text="Include Obsolete" Value="Include Obsolete" />
</asp:CheckBoxList>
</td>
</tr>
</table>
</div>
<div style="float: left; margin-left: 10px;">
<table class="custom_table custom_border" cellpadding="0" cellspacing="0" width="210">
<tr>
<td class="custom_border_bottom" style="padding-left: 6px; padding-right: 5px;">
<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<td>
<strong>Search History</strong>
</td>
<td style="text-align: right;">
<strong>
<asp:CheckBox ID="History_All" runat="server" Text="All" Checked="True" onclick="ToggleHistory(this.checked)" /></strong>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="custom_border_bottom">
<asp:CheckBoxList ID="History_Fields" runat="server">
<asp:ListItem Text="ID Number" Selected="True" />
<asp:ListItem Text="Inspector" Selected="True" />
<asp:ListItem Text="Inspector E-mail" Selected="True" />
<asp:ListItem Text="Remarks" Selected="True" />
</asp:CheckBoxList>
</td>
</tr>
<tr>
<td class="custom_border_bottom">
<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<td>
<strong>Approval</strong>
</td>
<td style="text-align: right;">
<strong>
<asp:CheckBox ID="History_Status_All" runat="server" Text="All" Checked="true" onclick="ToggleHistory_Status(this.checked)" /></strong>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<asp:CheckBoxList ID="History_Status" runat="server">
<asp:ListItem Text="None" Value="0" Selected="True" />
<asp:ListItem Text="Accepted" Value="1" Selected="True" />
<asp:ListItem Text="Rejected" Value="2" Selected="True" />
</asp:CheckBoxList>
</td>
</tr>
</table>
</div>
<div style="float: left; margin-left: 10px;">
<table class="custom_table custom_border" cellpadding="0" cellspacing="0" width="210">
<tr>
<td class="custom_border_bottom" style="padding-left: 6px; padding-right: 5px;">
<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<td>
<strong>Search OTR</strong>
</td>
<td style="text-align: right;">
<strong>
<asp:CheckBox ID="OTR_All" runat="server" Text="All" Checked="True" onclick="ToggleOTR(this.checked)" /></strong>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="custom_border_bottom">
<asp:CheckBoxList ID="OTR_Fields" runat="server">
<asp:ListItem Text="ID Number" Selected="True" />
<asp:ListItem Text="Submitter" Selected="True" />
<asp:ListItem Text="Submitter E-mail" Selected="True" />
<asp:ListItem Text="Actual accuracy" Selected="True" />
</asp:CheckBoxList>
</td>
</tr>
<tr>
<td class="custom_border_bottom">
<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<td>
<strong>Classification</strong>
</td>
<td style="text-align: right;">
<strong>
<asp:CheckBox ID="OTR_Classification_All" runat="server" Text="All" Checked="true" onclick="ToggleOTR_Classification(this.checked)" /></strong>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<asp:CheckBoxList ID="OTR_Classification" runat="server">
<asp:ListItem Text="Slight" Value="1" Selected="True" />
<asp:ListItem Text="Significant" Value="2" Selected="True" />
</asp:CheckBoxList>
</td>
</tr>
</table>
</div>
<div style="float: left; margin-left: 10px;">
<table class="custom_table custom_border" cellpadding="0" cellspacing="0">
<tr>
<td class="custom_border_bottom" style="padding-left: 5px;">
<strong>
<asp:CheckBox ID="Filter_By_Date" runat="server" Text="Search by Date" onclick="ToggleDates(this.checked)" /></strong>
</td>
</tr>
<tr>
<td class="custom_border_bottom">
<telerik:RadDatePicker ID="Date_Start" runat="server" Enabled="false" Width="110" />
<telerik:RadDatePicker ID="Date_End" runat="server" Enabled="false" Width="110" />
</td>
</tr>
</table>
</div>
</div>
</div>
<br />
<table cellspacing="0" cellpadding="0">
<tr>
<td>
<telerik:RadGrid ID="Results" runat="server" AllowPaging="true" PageSize="250" AllowSorting="true" OnItemDataBound="Results_ItemDataBound" OnNeedDataSource="Results_NeedDataSource">
<MasterTableView AutoGenerateColumns="false" PagerStyle-Position="TopAndBottom" CommandItemDisplay="TopAndBottom">
<CommandItemTemplate>
<div style="padding: 5px; float: right;">
<telerik:RadButton ID="DataDump" runat="server" Text="Data Dump" OnClick="DataDump_Click" Skin="Outlook" />
</div>
</CommandItemTemplate>
<Columns>
<telerik:GridTemplateColumn DataField="id_label" SortExpression="id_label_length, id_label" HeaderText="ID #" HeaderStyle-Width="150">
<ItemTemplate>
<a href='View.aspx?id=<%# Eval("id") %>'>
<%# Eval("id_label") %></a>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn DataField="type" HeaderText="Type" HeaderStyle-Width="120" />
<telerik:GridBoundColumn DataField="description" HeaderText="Description" HeaderStyle-Width="600" />
</Columns>
</MasterTableView>
</telerik:RadGrid>
</td>
</tr>
</table>
<div style="padding-top: 10px; padding-bottom: 10px;">
<strong>Wildcards</strong><br />
The percent sign '%' allows for the substitution of any number characters (0, 1 or more).<br />
The underscore '_' allows for the substitution of exactly 1 character. It is cumulative so you can use '__' to substitute 2 characters for example.
</div>
</div>
</asp:Content>
链接到CS:https://drive.google.com/file/d/0B-cYAOqWVWFjUnJBeC1MTFZBcjA/view?usp=sharing
上传太长了,我不知道是否有其他方式。
答案 0 :(得分:0)
您可以像这样保存参数值:
ArrayList parameterList = new ArrayList();
parameterList.Add(txtFirstParameter.Text);
parameterList.Add(txtSecondParameter.Text);
Session["parameterList"] = parameterList;
要检索值,只需引用Session变量并转换回ArrayList
var parameterList = (ArrayList)Session["parameterList"];
var parameterOne = parameterList[0].ToString()