Click here to Skip to main content
15,911,711 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
In my web application i have integrated a Chat Application developed in asp.net, Jquery and web services using sql server 2008. and i create a user control for it. i use this user control at master page.


my problem is-- i m in a chatting if there is any postback than chatbox is closed for every postback how to handle this problem please help me....


thanks in advance...
Posted

Hi Kirti,

As per my understanding of the problem is when you postback your page, everything is lost from the page.

I think you have to restrict postback. If that's not feasible solution as per the requirement, then you may think of implementing partial postback so that controls created using JavaScript are not sent back to server hence the controls will not get lost over the postback.

Please let me know if there are any further queries.

-DD
 
Share this answer
 
Comments
Kriti Sharma 10400841 16-Jun-14 0:23am    
how can i implement partial postback in master page if i use a user control or jquery to implement chat on application... please guide me
[no name] 19-Jun-14 7:54am    
Dear Kirti,

You can send request to server using jQuery with the help of AJAX.
Try this :

Add below condition in "Page_Load" event of master page


C#
if (!Page.IsPostBack)
{
    //Your Code
}
 
Share this answer
 
Comments
Kriti Sharma 10400841 13-Jun-14 7:02am    
my problem is that chatbox is closing after postback how to prevent to closing it...
my chatbox is created using javascript with user id..
i am able to create many chat boxes for every user at the same time how to prevent to close all the chatboxes at page post back as they are created using jquery or javascript..
[no name] 17-Jun-14 6:31am    
Dear Kriti,

Please share your code. So I can give you a proper solution.
[no name] 20-Jun-14 11:57am    
I think solution 3 is the right answer for you
Add below code in Code Behind Page:
C#
if (IsPostBack)
{
    //Registering HiddenField for PostBack
    ClientScript.RegisterHiddenField("IsPostBack", "1");
}



JQuery Code:
JavaScript
if ($("#IsPostBack").val() != "")
{
    //This will execute when PostBack is false
    //Write your code here
}



Javascript Code:
JavaScript
var IsPostBack = document.getElementById("IsPostBack").value;
if (IsPostBack = "1") {
    //This will execute when PostBack is true
    //Write your code here
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900