Click here to Skip to main content
15,886,199 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionHow do you clear temporary files in an ASP.NET website project? Pin
Xarzu15-Jul-13 0:25
Xarzu15-Jul-13 0:25 
AnswerRe: How do you clear temporary files in an ASP.NET website project? Pin
Ali Al Omairi(Abu AlHassan)15-Jul-13 2:08
professionalAli Al Omairi(Abu AlHassan)15-Jul-13 2:08 
AnswerRe: How do you clear temporary files in an ASP.NET website project? Pin
bVagadishnu15-Jul-13 7:22
bVagadishnu15-Jul-13 7:22 
Questionhow to end the session of chrome browser in asp.net (it is working in IE but not in Chrome) Pin
ven75314-Jul-13 7:14
ven75314-Jul-13 7:14 
AnswerRe: how to end the session of chrome browser in asp.net (it is working in IE but not in Chrome) Pin
jkirkerx14-Jul-13 12:46
professionaljkirkerx14-Jul-13 12:46 
GeneralRe: how to end the session of chrome browser in asp.net (it is working in IE but not in Chrome) Pin
ven75315-Jul-13 2:08
ven75315-Jul-13 2:08 
GeneralRe: how to end the session of chrome browser in asp.net (it is working in IE but not in Chrome) Pin
jkirkerx15-Jul-13 13:16
professionaljkirkerx15-Jul-13 13:16 
QuestionHttpContext values are lost during AJAX call after Adding masterpage Pin
Albert8313-Jul-13 22:29
Albert8313-Jul-13 22:29 
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:

<script>
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);
}
</script>
<asp:HiddenField ID="hdnSenderID" runat="server" />
<asp:HiddenField ID="hdnReceiverID" runat="server" />
<asp:HiddenField ID="hdnDays" runat="server" />

<a style="cursor: pointer;" onclick="SavePostedMessage()">

<div style="height: 25px; width: 85px; float: left; margin-top: 28px; padding-top: 5px;

background: #01B2E5; text-align: center;" id="uploadifyContainer"> 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');
}
});
}

function SaveMessageInDatabase(SenderAccountID, ReceiverAccountID, Body, days) {

$.ajax({
type: "POST",
url: "/MessageFacebox/SaveMessage.ashx",
data: 'SenderID=' + SenderAccountID + "&ReceiverID=" + ReceiverAccountID + "&Body=" + Body,
success: function (data) {
GetMessageConversation(SenderAccountID, ReceiverAccountID, days);
},
error: function () {
alert('Sorry some error occurred');
}
});

In GetMessageConversation.ashx context.Request.Form["SenderAccountID"] and context.Request.Form["ReceiverAccountID"] return stored values

Account senderAccount = _accountRepository.GetAccountByAccountID(Convert.ToInt32(context.Request.Form["SenderAccountID"]));
Account receiverAccount = _accountRepository.GetAccountByAccountID(Convert.ToInt32(context.Request.Form["ReceiverAccountID"]));

But in SaveMessage.ashx Account senderAccount = _accountRepository.GetAccountByAccountID(Convert.ToInt32(context.Request.Form["SenderID"])) ; Account receiverAccount = _accountRepository.GetAccountByAccountID(Convert.ToInt32(context.Request.Form["ReceiverID"] ));

context.Request.Form["SenderID"] and context.Request.Form["ReceiverID"] have null values.

the first one loads when the page is first accessed. The save function is called when user enters a message and click on send button in messages.aspx

All works fine without a master page. Once I add masterpage file to messages.aspx the code stops working.

Thanks in advance.
AnswerRe: HttpContext values are lost during AJAX call after Adding masterpage Pin
jkirkerx14-Jul-13 8:53
professionaljkirkerx14-Jul-13 8:53 
AnswerRe: HttpContext values are lost during AJAX call after Adding masterpage Pin
Albert8317-Aug-13 17:08
Albert8317-Aug-13 17:08 
QuestionThe file you are trying to open,XXXX,is in different format than specified by the file extension Pin
Jimmiraghu13-Jul-13 2:23
Jimmiraghu13-Jul-13 2:23 
AnswerRe: The file you are trying to open,XXXX,is in different format than specified by the file extension Pin
Bernhard Hiller14-Jul-13 21:58
Bernhard Hiller14-Jul-13 21:58 
Questionsample projects required Pin
ppayal12-Jul-13 20:29
ppayal12-Jul-13 20:29 
AnswerRe: sample projects required Pin
Richard MacCutchan12-Jul-13 22:19
mveRichard MacCutchan12-Jul-13 22:19 
QuestionExport to excel /xlsx file Pin
Ballita12-Jul-13 1:53
Ballita12-Jul-13 1:53 
AnswerRe: Export to excel /xlsx file Pin
ZurdoDev12-Jul-13 7:25
professionalZurdoDev12-Jul-13 7:25 
Questionimage icon should display from data base on leftside of treeview. Pin
christhuxavier11-Jul-13 3:15
christhuxavier11-Jul-13 3:15 
AnswerRe: image icon should display from data base on leftside of treeview. Pin
jkirkerx11-Jul-13 11:58
professionaljkirkerx11-Jul-13 11:58 
QuestionSelect Excel File as Database table in runtime - ASP.Net - C# Pin
SravanKumar-A11-Jul-13 2:51
SravanKumar-A11-Jul-13 2:51 
AnswerRe: Select Excel File as Database table in runtime - ASP.Net - C# Pin
chester_it2111-Jul-13 8:59
chester_it2111-Jul-13 8:59 
QuestionMigration from google calendar V2 to V3 Pin
Er Himanshu Jain11-Jul-13 2:13
Er Himanshu Jain11-Jul-13 2:13 
AnswerRe: Migration from google calendar V2 to V3 Pin
Richard MacCutchan11-Jul-13 2:27
mveRichard MacCutchan11-Jul-13 2:27 
AnswerRe: Migration from google calendar V2 to V3 Pin
Er Himanshu Jain11-Jul-13 2:34
Er Himanshu Jain11-Jul-13 2:34 
GeneralWSDL issues Pin
asv10-Jul-13 22:48
asv10-Jul-13 22:48 
SuggestionRe: WSDL issues Pin
Richard MacCutchan10-Jul-13 23:13
mveRichard MacCutchan10-Jul-13 23:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.