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