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. HttpContext values are lost during AJAX call after Adding masterpage

HttpContext values are lost during AJAX call after Adding masterpage

Scheduled Pinned Locked Moved ASP.NET
javascripthelphtmldesign
3 Posts 2 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
    Albert83
    wrote on last edited by
    #1

    it's been several days since I am trying to resolve this issue. I have a page that is a mail inbox in the website. You can send messages to your friends from the list like on facebook. It has AJAX code in a js file, 2 ashx files, and aspx, aspx.cs files. I was using facebox pop up when a user wanted to send a message to a friend. Now I changed the UI removed facebox and added a masterpage so that now the page is like any other page on the site. But after adding a masterpage to messages.aspx page the values of HttpContext become null after I click on send message. They are working fine when the page first loads that shows friends list and previous messages. It's when I fire a js function to save the message entered by clicking send that it's lost. in message.aspx page I use 3 hidden fields: function SavePostedMessage() { var SenderAccountID = $("#hdnSenderID").val(); var ReceiverAccountID = $("#hdnReceiverID").val(); var Days = $("#hdnDays").val(); var body = GetmessageData(); if (body != null || body != "") SaveMessageInDatabase(SenderAccountID, ReceiverAccountID, body, Days); }

    Send In messages.aspx.cs I put in page_load the code to register a js function: ScriptManager.RegisterStartupScript(this, typeof(string), "Play", "javascript:GetMessageConversation('" + Request.QueryString["AccountID"] + "','" + _userSession.CurrentUser.AccountID + "','7');", true); In Ajax.js I defined function GetMessageConversation(SenderAccountID, ReceiverAccountID, Days) { $("#hdnSenderID").val(SenderAccountID); $("#hdnReceiverID").val(ReceiverAccountID); $("#hdnDays").val(Days); $("#divPostComment").show(); setSelected("trUser" + ReceiverAccountID); $.ajax({ type: "POST", url: "/MessageFacebox/GetMessageConversation.ashx", data: 'SenderAccountID=' + SenderAccountID + "&ReceiverAccountID=" + ReceiverAccountID + "&Days=" + Days, success: function (data) { $('#messageconversationdata').html(data); Scrollbottom(); }, error: function (errordata) { alert('Sorry some error occurred');

    J 1 Reply Last reply
    0
    • A Albert83

      it's been several days since I am trying to resolve this issue. I have a page that is a mail inbox in the website. You can send messages to your friends from the list like on facebook. It has AJAX code in a js file, 2 ashx files, and aspx, aspx.cs files. I was using facebox pop up when a user wanted to send a message to a friend. Now I changed the UI removed facebox and added a masterpage so that now the page is like any other page on the site. But after adding a masterpage to messages.aspx page the values of HttpContext become null after I click on send message. They are working fine when the page first loads that shows friends list and previous messages. It's when I fire a js function to save the message entered by clicking send that it's lost. in message.aspx page I use 3 hidden fields: function SavePostedMessage() { var SenderAccountID = $("#hdnSenderID").val(); var ReceiverAccountID = $("#hdnReceiverID").val(); var Days = $("#hdnDays").val(); var body = GetmessageData(); if (body != null || body != "") SaveMessageInDatabase(SenderAccountID, ReceiverAccountID, body, Days); }

      Send In messages.aspx.cs I put in page_load the code to register a js function: ScriptManager.RegisterStartupScript(this, typeof(string), "Play", "javascript:GetMessageConversation('" + Request.QueryString["AccountID"] + "','" + _userSession.CurrentUser.AccountID + "','7');", true); In Ajax.js I defined function GetMessageConversation(SenderAccountID, ReceiverAccountID, Days) { $("#hdnSenderID").val(SenderAccountID); $("#hdnReceiverID").val(ReceiverAccountID); $("#hdnDays").val(Days); $("#divPostComment").show(); setSelected("trUser" + ReceiverAccountID); $.ajax({ type: "POST", url: "/MessageFacebox/GetMessageConversation.ashx", data: 'SenderAccountID=' + SenderAccountID + "&ReceiverAccountID=" + ReceiverAccountID + "&Days=" + Days, success: function (data) { $('#messageconversationdata').html(data); Scrollbottom(); }, error: function (errordata) { alert('Sorry some error occurred');

      J Offline
      J Offline
      jkirkerx
      wrote on last edited by
      #2

      Did you test your data before transmuting, so you can isolate the problem between the client or server side?

      alert('SenderAccountID=' + SenderAccountID + "&ReceiverAccountID=" + ReceiverAccountID + "&Days=" + Days,);

      When changing to a masterpage, the id's change on the textboxes and labels, so a Ct100 is added as a prefix to the id of the element. so you can change the id mode of the control to static, or change the way jquery finds the element to a wildcard prefix and then the id name.

      A 1 Reply Last reply
      0
      • J jkirkerx

        Did you test your data before transmuting, so you can isolate the problem between the client or server side?

        alert('SenderAccountID=' + SenderAccountID + "&ReceiverAccountID=" + ReceiverAccountID + "&Days=" + Days,);

        When changing to a masterpage, the id's change on the textboxes and labels, so a Ct100 is added as a prefix to the id of the element. so you can change the id mode of the control to static, or change the way jquery finds the element to a wildcard prefix and then the id name.

        A Offline
        A Offline
        Albert83
        wrote on last edited by
        #3

        Thanks for responding. That was the issue.

        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