My problem. I have an GridView inside an updatePanel. When I click in a button inside the gridview it redirects to another page. But when I click in back button in browser gets to the same page as before but with Session["Id"] changed. And it does PageLoad when I click at any item inside the page. It there's a way if I click back button that or redirect to first page or give me the same page as before with the same Sessions and not enter PageLoad?? thanks
//My ScriptManager
<asp:ScriptManager ID="ScriptManager1" runat="server" EnableHistory="true" EnableSecureHistoryState="false"
EnablePartialRendering="true" OnNavigate="ScriptManager1_Navigate">
</asp:ScriptManager>
//My update panel:
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always">
//My gridView:
<asp:GridView ID="grid" runat="server" EnableModelValidation="true" AutoGenerateColumns="false"
AllowPaging="true" PageSize="20" Width="100%" Font-Size="Smaller" OnRowDataBound="grid_RowDataBound"
OnPageIndexChanging="grid_PageIndexChanging"
OnRowCommand="grid_RowCommand">
<HeaderStyle ForeColor="White" />
<Columns>
<asp:BoundField HeaderText="Name" DataField="name">
<ItemStyle />
</asp:BoundField>
<asp:BoundField HeaderText="id" DataField="id">
<ItemStyle />
</asp:BoundField>
<asp:BoundField HeaderText="AnotherField" DataField="anotherField">
<ItemStyle />
</asp:BoundField>
<asp:BoundField HeaderText="AnotherField2" DataField="anotherField">
<ItemStyle />
</asp:BoundField>
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="btnRedirect" runat="server" CommandArgument='<%#DataBinder.Eval(Container.DataItem,"id") %>' CommandName="redirect"
ToolTip="Redirect" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
//My Code Behind:
protected void ScriptManager1_Navigate(object sender, HistoryEventArgs e) // Event handler for restoring state
{
Session["Id"] = e.State["value"];
}
protected void grid_RowCommand(object sender, GridViewCommandEventArgs e)
{
string id= Convert.ToString(e.CommandArgument);
if (e.CommandName == "redirect")
{
ScriptManager.GetCurrent(Page).AddHistoryPoint("value", idInThePage);
Session["TipoDocumento"] = id;
Response.Redirect("RedirectPage.aspx");
}
}