Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Response.Write in aspx file

Response.Write in aspx file

Scheduled Pinned Locked Moved ASP.NET
questiondatabasedesign
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Abdul Rahman Hamidy
    wrote on last edited by
    #1

    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

    V M 2 Replies Last reply
    0
    • A Abdul Rahman Hamidy

      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

      V Offline
      V Offline
      Viral Upadhyay
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • A Abdul Rahman Hamidy

        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

        M Offline
        M Offline
        Martin Jarvis
        wrote on last edited by
        #3

        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.

        A 1 Reply Last reply
        0
        • M Martin Jarvis

          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.

          A Offline
          A Offline
          Abdul Rahman Hamidy
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups