javs1983
Programmer
- Apr 17, 2008
- 2
'm working on a huge code base, so have made a small sample to simulate the issue that I am currently facing.
This is my aspx file:-
<%@ PageLanguage="C#"AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""
<html xmlns="
<head runat="server">
<title>UntitledPage</title>
</head>
<body>
<form id="form1" runat="server">
<input type ="hidden" name="inp_hid" value = "popupIsClosed"/>
<div>
<br />
<asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">POPUP</asp:LinkButton><br />
<br />
<br />
<asp:LinkButton ID="LinkButton2" runat="server" OnClick="LinkButton2_Click">TEXTBOX</asp:LinkButton><br />
<br />
<br />
<asp:TextBox ID="TextBox1" Visible="false" runat="server"></asp:TextBox> </div>
</form>
</body>
</html>
And, this is my code-behind:
using System;
usingSystem.Data;
usingSystem.Configuration;
usingSystem.Web;
usingSystem.Web.Security;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
usingSystem.Web.UI.WebControls.WebParts;
usingSystem.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(objectsender, EventArgs e)
{
}
protected void LinkButton1_Click(objectsender, EventArgs e)
{
stringstrScript = "<scriptlanguage=javascript>window.open('
Page.ClientScript.RegisterStartupScript(typeof(string),"Start",strScript);
}
protected void LinkButton2_Click(objectsender, EventArgs e)
{
TextBox1.Visible = true;
}
}
Steps to simulate :-
1. Click on the link button that has the text "POPUP",the popup shows
2. next click on the link button that has the text "TEXTBOX",the textbox becomes visible.
3. Click on the back button and the pop-up shows again.
Issue:-
In my actual code I am working on a nested master page architecture,so I can't use "Resposnse.Write" to write the javascript as that disturbs the alignment of my page.
So, what I was doing was trying to disable the server side and the client side cache so that the page can be executed fresh.
I did that and the cache is deleted.
But now the issue is that when I click on the back button,it says that the page has expired and asks me to refresh the page when I do so,the back button does a postback and the popup comes again.
This is what I tried, it works the first time but fails the second time.Please help:-(
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.Cache.SetCacheability(HttpCacheability.NoCache);
if (!this.IsPostBack)
{
Session["update"] = "xxxx";
}
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
if (Session["update"].ToString() == ViewState["update"].ToString())
{
string strScript = "<script>window.open('
Page.ClientScript.RegisterClientScriptBlock(typeof(string), "Start", strScript);
}
Session["update"] = " ";
}
protected void LinkButton2_Click(object sender, EventArgs e)
{
TextBox1.Visible = true;
}
protected void Page_PreRender(object sender, EventArgs e)
{
ViewState["update"] = Session["update"];
}
}
Please help.
Thanks
This is my aspx file:-
<%@ PageLanguage="C#"AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""
<html xmlns="
<head runat="server">
<title>UntitledPage</title>
</head>
<body>
<form id="form1" runat="server">
<input type ="hidden" name="inp_hid" value = "popupIsClosed"/>
<div>
<br />
<asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">POPUP</asp:LinkButton><br />
<br />
<br />
<asp:LinkButton ID="LinkButton2" runat="server" OnClick="LinkButton2_Click">TEXTBOX</asp:LinkButton><br />
<br />
<br />
<asp:TextBox ID="TextBox1" Visible="false" runat="server"></asp:TextBox> </div>
</form>
</body>
</html>
And, this is my code-behind:
using System;
usingSystem.Data;
usingSystem.Configuration;
usingSystem.Web;
usingSystem.Web.Security;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
usingSystem.Web.UI.WebControls.WebParts;
usingSystem.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(objectsender, EventArgs e)
{
}
protected void LinkButton1_Click(objectsender, EventArgs e)
{
stringstrScript = "<scriptlanguage=javascript>window.open('
Page.ClientScript.RegisterStartupScript(typeof(string),"Start",strScript);
}
protected void LinkButton2_Click(objectsender, EventArgs e)
{
TextBox1.Visible = true;
}
}
Steps to simulate :-
1. Click on the link button that has the text "POPUP",the popup shows
2. next click on the link button that has the text "TEXTBOX",the textbox becomes visible.
3. Click on the back button and the pop-up shows again.
Issue:-
In my actual code I am working on a nested master page architecture,so I can't use "Resposnse.Write" to write the javascript as that disturbs the alignment of my page.
So, what I was doing was trying to disable the server side and the client side cache so that the page can be executed fresh.
I did that and the cache is deleted.
But now the issue is that when I click on the back button,it says that the page has expired and asks me to refresh the page when I do so,the back button does a postback and the popup comes again.
This is what I tried, it works the first time but fails the second time.Please help:-(
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.Cache.SetCacheability(HttpCacheability.NoCache);
if (!this.IsPostBack)
{
Session["update"] = "xxxx";
}
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
if (Session["update"].ToString() == ViewState["update"].ToString())
{
string strScript = "<script>window.open('
Page.ClientScript.RegisterClientScriptBlock(typeof(string), "Start", strScript);
}
Session["update"] = " ";
}
protected void LinkButton2_Click(object sender, EventArgs e)
{
TextBox1.Visible = true;
}
protected void Page_PreRender(object sender, EventArgs e)
{
ViewState["update"] = Session["update"];
}
}
Please help.
Thanks