Response.Write in aspx file
-
Dear All, I have following code in PageLoad Event
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack) //------I
Session["FilteredTable"] = string.Empty;
if (Page.IsPostBack) //-------II
{
try
{
bindSelectedFields();
bindReport();
}
catch (Exception ex)
{
Response.Write(ex.Message + "<br>"+ ex.StackTrace);
}
}
}and the same I have Code in design time
<table id="tFilterButton" ><%Response.Write(hidRmvFilter.Value);%></table>
which hidRmvFilter is hidden field. the thing is I want to empty session variable at first visit of page. but in above code I dont know what is wrong which the session gets empty at any postback. I debugged the code and checked that when it reaches
<table id="tFilterButton" ><%Response.Write(hidRmvFilter.Value);%></table>
it again goes to the first IF block (I). any ideas why the session gets empty at each postback or I am looking to an alternative to store session variable at any postback which it should get empty only in first page visit?
Abdul Rahaman Hamidy Database Developer Kabul, Afghanistan
-
Dear All, I have following code in PageLoad Event
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack) //------I
Session["FilteredTable"] = string.Empty;
if (Page.IsPostBack) //-------II
{
try
{
bindSelectedFields();
bindReport();
}
catch (Exception ex)
{
Response.Write(ex.Message + "<br>"+ ex.StackTrace);
}
}
}and the same I have Code in design time
<table id="tFilterButton" ><%Response.Write(hidRmvFilter.Value);%></table>
which hidRmvFilter is hidden field. the thing is I want to empty session variable at first visit of page. but in above code I dont know what is wrong which the session gets empty at any postback. I debugged the code and checked that when it reaches
<table id="tFilterButton" ><%Response.Write(hidRmvFilter.Value);%></table>
it again goes to the first IF block (I). any ideas why the session gets empty at each postback or I am looking to an alternative to store session variable at any postback which it should get empty only in first page visit?
Abdul Rahaman Hamidy Database Developer Kabul, Afghanistan
I think the problem is in your functions
Abdul Rahman Hamidy wrote:
bindSelectedFields(); bindReport();
May be the functions causing postback again. Try to check it again.
Viral My Site
Save Our Tigers -
Dear All, I have following code in PageLoad Event
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack) //------I
Session["FilteredTable"] = string.Empty;
if (Page.IsPostBack) //-------II
{
try
{
bindSelectedFields();
bindReport();
}
catch (Exception ex)
{
Response.Write(ex.Message + "<br>"+ ex.StackTrace);
}
}
}and the same I have Code in design time
<table id="tFilterButton" ><%Response.Write(hidRmvFilter.Value);%></table>
which hidRmvFilter is hidden field. the thing is I want to empty session variable at first visit of page. but in above code I dont know what is wrong which the session gets empty at any postback. I debugged the code and checked that when it reaches
<table id="tFilterButton" ><%Response.Write(hidRmvFilter.Value);%></table>
it again goes to the first IF block (I). any ideas why the session gets empty at each postback or I am looking to an alternative to store session variable at any postback which it should get empty only in first page visit?
Abdul Rahaman Hamidy Database Developer Kabul, Afghanistan
Provided your bindSelectedFields() and bindReport() are correct, this should work. But only if you're actually performing a Postback (clicked button or similar). It won't work on a first visit per session basis if your requesting the page via a GET (such as clicking a link, or navigating directly to the page in the address bar.
-
Provided your bindSelectedFields() and bindReport() are correct, this should work. But only if you're actually performing a Postback (clicked button or similar). It won't work on a first visit per session basis if your requesting the page via a GET (such as clicking a link, or navigating directly to the page in the address bar.
thanks for reply, Would you please give me more information bz yours is not so clear for me.
Abdul Rahaman Hamidy Database Developer Kabul, Afghanistan