473,394 Members | 1,932 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

How to Refresh a particular part of a web page ?

Ganesh9u
How to Refresh a particular part of a web page ?

Example :
I want to refresh a particular element <div ></div>

in the asp.net page. using Ajax
Oct 13 '08 #1
15 16260
acoder
16,027 Expert Mod 8TB
You can access it using document.getElementById() and then set its innerHTML property (or use DOM methods, e.g. appendChild(), replaceChild()).
Oct 13 '08 #2
You can access it using document.getElementById() and then set its innerHTML property (or use DOM methods, e.g. appendChild(), replaceChild()).
Yes you are right, but when i used this type, it does not works when the page is posted back.

and I must refresh the particular content without postback from the server.
Eg
my code
Expand|Select|Wrap|Line Numbers
  1. if (Request.QueryString["SendRequest"] != null)
  2.         {
  3.             if (Request.QueryString["SendRequest"].Equals("userlist"))
  4.             {
  5.                 GetUserList();
  6.                 Response.End();
  7.             }
  8.             if (Request.QueryString["SendRequest"].Equals("UserData"))
  9.             {                
  10.                 GetIndividualReport(Request.QueryString["d1"], Request.QueryString["d2"], Request.QueryString["user"]);                
  11.                 Response.End();
  12.             }
  13.         }
  14.  
Works well when I refresh.
Oct 13 '08 #3
acoder
16,027 Expert Mod 8TB
Post your Ajax code (using code tags).
Oct 13 '08 #4
Expand|Select|Wrap|Line Numbers
  1. function GetAgentList()
  2.     {
  3.         var xmlHttp = GetXmlHttp();
  4.             xmlHttp.onreadystatechange=function()
  5.                 {
  6.                 if(xmlHttp.readyState==4)
  7.                   {                      
  8.  
  9.                   DisplayData(xmlHttp.responseText);
  10.                   }
  11.                 }                  
  12.            xmlHttp.open("GET","Report.aspx?SendRequest=userlist",true);  xmlHttp.send(null); 
  13.     }
  14.  
  15.        function DisplayData(info)
  16.              {
  17.                 var data = info.split("*");
  18.  
  19.                 if(data[0] == 'Err')
  20.                 {
  21.                     if(data[1] == 'N')
  22.                     {
  23.                         alert('7 Days is the maximum date range!!');
  24.                     }
  25.                     //document.getElementById('divMsg').innerHTML = data[1];
  26.                 }
  27.                 else if(data[0] == 'Msg')
  28.                 {                
  29.                     //document.getElementById('divMsg').innerHTML = data[1];
  30.                     alert(data[1]);
  31.                 }
  32.                 else if(data[0] == 'Data')
  33.                 {                      
  34.                   document.getElementById('AgentList').innerHTML = data[1];                   
  35.                 }
  36.  
  37.  
  38.              }
Oct 14 '08 #5
acoder
16,027 Expert Mod 8TB
Where do you make the call to GetAgentList()?

Please post code using code tags. Thanks.
Oct 14 '08 #6
Where do you make the call to GetAgentList()?
When I click a button control form html page. do you understand.
Oct 15 '08 #7
acoder
16,027 Expert Mod 8TB
Yes, can you post the button code (on the client-side [view source] in the browser).
Oct 15 '08 #8
Expand|Select|Wrap|Line Numbers
  1.  function GetAgentList()
  2.     {
  3.         var xmlHttp = GetXmlHttp();
  4.             xmlHttp.onreadystatechange=function()
  5.                 {
  6.                 if(xmlHttp.readyState==4)
  7.                   {                                                
  8.                   DisplayData(xmlHttp.responseText);
  9.                   }
  10.                 }                  
  11.            xmlHttp.open("GET","Report.aspx?SendRequest=userlist",true);  xmlHttp.send(null); 
  12.     }
Oct 15 '08 #9
acoder
16,027 Expert Mod 8TB
You already posted that. I meant the button code which calls this function onclick.
Oct 15 '08 #10
[HTML] <img id="btnGenerate" runat="server" alt="Generate Report"
onclick ="PleaseWait();GetAgentList();"
src="Images/generate_report_button.gif" />[/HTML]
Oct 15 '08 #11
acoder
16,027 Expert Mod 8TB
That seems OK, so that leaves the server-side script. If you run the page Report.aspx?SendRequest=userlist directly (without Ajax - type in your address bar), what does it output? Is it what you expect?
Oct 15 '08 #12
Not like that, It gives output to me, but i refresh it the content in my div tag is lost. And the next time when i execute the same i got the correct result.
Oct 15 '08 #13
acoder
16,027 Expert Mod 8TB
That was only for a test to determine if you're getting the correct output from your server-side code.

I think the best thing would be for you to post the whole code (client-side version), or better still, a link to a test page.
Oct 15 '08 #14
Plater
7,872 Expert 4TB
I am guessing that since the button is also a server control, it causes a postback..which happens AFTER the other javascript is run. So the DIV tag gets refreshed, but a postback occurs and the contents are then lost?
Oct 15 '08 #15
I am guessing that since the button is also a server control, it causes a postback..which happens AFTER the other javascript is run. So the DIV tag gets refreshed, but a postback occurs and the contents are then lost?
What about view state can i use that ?
Oct 16 '08 #16

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Conax | last post by:
Hi there, My boss is hoping that I can come up with a page that displays some information. The information will always be displayed on specific part of the page, with auto refresh. But he...
1
by: dabingyoutiao | last post by:
HI. I just started to writer my first asp.net web application. Could any one tell me how to refresh the web page programmatically?The language I am using is C#. I know this question is too simple....
1
by: Spencer H. Prue | last post by:
I am looking to set a particular web page as my startup page. That Is when the program starts I want to have a particular web page loaded instead of the default page. How do I specify this? Thanks....
3
by: PhilBowen | last post by:
How do you print a particular part of a form. In excel you can go to "print area".
3
by: vikramcbz | last post by:
is it possible to refresh a part of the page in jsp using ajax if it possible please help....................!!!!
1
by: rprajendra | last post by:
helo i need code for only one part refresh in a page
1
by: ravitunk | last post by:
hello all.....Is there a way to refresh an ASP.net page from SQL Server 2000??????? or i also have an after insert trigger for a table.....Can i refresh ASP.net page from trigger?????
2
by: baburmm | last post by:
hai, How to change the particular part i.e., closed surface like rectangle or circle in an image, i want to change the rectangle colour inside my image using C#.net Thanks in advance, ...
7
by: techuse | last post by:
i have the following code in ajax.can you help how to refresh the particular part of the div or part of the web page? here in this code the record is inserted but the div isnot get refreshed. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.