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
15 16260
You can access it using document.getElementById() and then set its innerHTML property (or use DOM methods, e.g. appendChild(), replaceChild()).
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 - if (Request.QueryString["SendRequest"] != null)
-
{
-
if (Request.QueryString["SendRequest"].Equals("userlist"))
-
{
-
GetUserList();
-
Response.End();
-
}
-
if (Request.QueryString["SendRequest"].Equals("UserData"))
-
{
-
GetIndividualReport(Request.QueryString["d1"], Request.QueryString["d2"], Request.QueryString["user"]);
-
Response.End();
-
}
-
}
-
Works well when I refresh.
Post your Ajax code (using code tags).
- function GetAgentList()
-
{
-
var xmlHttp = GetXmlHttp();
-
xmlHttp.onreadystatechange=function()
-
{
-
if(xmlHttp.readyState==4)
-
{
-
-
DisplayData(xmlHttp.responseText);
-
}
-
}
-
xmlHttp.open("GET","Report.aspx?SendRequest=userlist",true); xmlHttp.send(null);
-
}
-
-
function DisplayData(info)
-
{
-
var data = info.split("*");
-
-
if(data[0] == 'Err')
-
{
-
if(data[1] == 'N')
-
{
-
alert('7 Days is the maximum date range!!');
-
}
-
//document.getElementById('divMsg').innerHTML = data[1];
-
}
-
else if(data[0] == 'Msg')
-
{
-
//document.getElementById('divMsg').innerHTML = data[1];
-
alert(data[1]);
-
}
-
else if(data[0] == 'Data')
-
{
-
document.getElementById('AgentList').innerHTML = data[1];
-
}
-
-
-
}
Where do you make the call to GetAgentList()?
Please post code using code tags. Thanks.
Where do you make the call to GetAgentList()?
When I click a button control form html page. do you understand.
Yes, can you post the button code (on the client-side [view source] in the browser).
- function GetAgentList()
-
{
-
var xmlHttp = GetXmlHttp();
-
xmlHttp.onreadystatechange=function()
-
{
-
if(xmlHttp.readyState==4)
-
{
-
DisplayData(xmlHttp.responseText);
-
}
-
}
-
xmlHttp.open("GET","Report.aspx?SendRequest=userlist",true); xmlHttp.send(null);
-
}
You already posted that. I meant the button code which calls this function onclick.
[HTML] <img id="btnGenerate" runat="server" alt="Generate Report"
onclick ="PleaseWait();GetAgentList();"
src="Images/generate_report_button.gif" />[/HTML]
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?
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.
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.
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?
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 ?
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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....
|
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....
|
by: PhilBowen |
last post by:
How do you print a particular part of a form. In excel you can go to "print area".
|
by: vikramcbz |
last post by:
is it possible to refresh a part of the page in jsp using ajax if it possible please help....................!!!!
|
by: rprajendra |
last post by:
helo
i need code for only one part refresh in a page
|
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?????
|
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,
...
|
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.
...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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...
|
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
|
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...
|
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...
|
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,...
|
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...
|
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...
| |