Thanks,
I have a page where a user enters a date and clicks a go button which displays the results in a grid, then the user clicks on a link in this grid which takes them to another page.
From this other page I have a close button which when clicked should redirect the user back to the previous search results.
This is the search page mark-up
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
<script type="text/javascript">
function popupCalendar(txtDateBox)
{
var SearchDate = document.getElementById('SearchDate');
txtDateBox.value = "";
if (SearchDate.style.display == 'none')
SearchDate.style.display = 'block';
else
SearchDate.style.display = 'none';
}
</script>
<table>
<tr>
<td>
<asp:Label ID="lblDays" runat="server" Text="Search"
CssClass="Text" />
</td>
<td>
<asp:TextBox ID="txtDateBox" runat="server" onclick="popupCalendar(this);"
ReadOnly="True" EnableViewState="false" CssClass="Text"/>
<asp:HiddenField id="dateval" runat="server" />
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ErrorMessage="Please select a date" ControlToValidate="txtDateBox"
Display="Dynamic" CssClass="Validation"/>
</td>
<td>
<asp:Button ID="btnSearch2" runat="server" Text="Go" CssClass="Text" />
</td>
</tr>
<tr>
<td colspan="1">
<asp:Label ID="lblDateResults" runat="server" CssClass="Text" />
</td>
</tr>
</table>
<div id="SearchDate" style="display:none; position:absolute; z-index:2;" class="SearchDate">
<asp:Calendar id="Calendar1" OnSelectionChanged="calDate_SelectionChanged"
Runat="server" BorderStyle="Solid" BorderWidth="1px" BorderColor="Black" WeekendDayStyle-Wrap="False"
DayHeaderStyle-ForeColor="Blue" DayHeaderStyle-VerticalAlign="Middle"
DayHeaderStyle-HorizontalAlign="Center"
OtherMonthDayStyle-CssClass="SearchDate" Font-Size="Small"
TitleStyle-BackColor="#009B00" ForeColor="White"
ondayrender="Calendar1_DayRender" BackColor="White">
<TodayDayStyle ForeColor="#FF6666" />
<WeekendDayStyle Wrap="False" />
<OtherMonthDayStyle ForeColor="#CCCCCC" />
<DayStyle Font-Underline="False" ForeColor="Black" />
<DayHeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" ForeColor="#5D7B9D"></DayHeaderStyle>
<TitleStyle BackColor="#5D7B9D" />
</asp:Calendar>
</div>
<br />
<br />
<div id="GridDiv" style="position:absolute; z-index:1;">
<asp:GridView ID="gridSearchResults" runat="server" CellPadding="4" ForeColor="#333333"
GridLines="None" AutoGenerateColumns="False" CssClass="Grid" >
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<Columns>
<asp:HyperLinkField Text="View/Edit" DataNavigateUrlFields="Id"
DataNavigateUrlFormatString="Order.aspx?id={0}" />
<asp:BoundField DataField="Name" HeaderText="Company Name" ReadOnly="True"
SortExpression="Name" />
<asp:BoundField DataField="DateRequired" HeaderText="Date Required"
ReadOnly="True" SortExpression="DateRequired"
DataFormatString="{0:dd/MM/yyyy}" />
</Columns>
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<EmptyDataTemplate>
Your search returned no results.
</EmptyDataTemplate>
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#999999" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>
</div>
<script type="text/javascript">
var txtDateBox = document.getElementById('<%= txtDateBox.ClientID%>');
var txtDateBox = document.getElementById('<%= txtDateBox.ClientID%>');
if (txtDateBox.value == "" && <%=IsPostBack == true ? "1" : "0" %> == "1")
{
var SearchDate = document.getElementById('SearchDate');
SearchDate.style.display = 'block';
}
if (<%=gridJobSearchResults.Visible == true ? "1" : "0" %> == "1")
{
var SearchDate = document.getElementById('SearchDate');
var txtDateBox = document.getElementById('<%= txtDateBox.ClientID%>');
var dateval = document.getElementById('<%= dateval.ClientID%>');
txtDateBox.value = dateval.value;
SearchDate.style.display = 'none';
}
</script>
</asp:Content>
This is the code behind page of the page that the user is taken to when they click on the link in the grid of the search results.
In the page load I wrote this - where I mentioned before I had the problem
protected void Page_Load(object sender, EventArgs e)
{
btnClose.Attributes.Add("onclick", "javascript:history.back(); return false;");
}
Is this any help. Can you see what needs to be done?