Showing posts with label stored. Show all posts
Showing posts with label stored. Show all posts

Wednesday, March 28, 2012

ViewState in Session is still uploaded after AsyncPostBack

Hi all,

Here is the basic setup of my page.

- ViewState stored in session
- AutoCompleteExtender using a WebService
- UpdatePanel triggered by button next to AutoComplete TextBox

Here is the behavior I'm experiencing (note that I have validated this with Fiddler):

Page loads first time. "id="__VIEWSTATE" value="y0V/cubnEZ1qzAvIgW0oRpVSc8AvJU6rtssTVFt7+B8="
ViewState is short as expected because storing it in the session.

Now, I click on the button to activate the UpdatePanel, causing a partial postback. This takes much longer than expected. After inspecting with Fiddler I see that it is uploading 50K. I inspect the Request and notice that most of it is my ViewState (I have a repeater on the page). I even turned EnableViewState off on the Repeater and it still uploads it.

My questions are:

1. Where is this uploaded ViewState coming from? It was not downloaded, is it generated clientside by JavaScript?
2. How can I stop this ViewState from being uploaded?

Regards,
Cole

I now realize this is not the viewstate but all of the form elements names & values being concatenated together. Is there a way to adjust what gets sent back from the controls on a AsyncPostBack?


The only way I'm aware of is to not use updatepanels to traffic your info, but instead to use web services, page methods, or hand-jam your own webrequest.

Saturday, March 24, 2012

Want to let datagrid load after page_load (AJAX)

Hello,

I have a datagrid that gets its data from a stored procedure (executed using a data adapter). It is quite slow, so I want the page to load everything first, display it to the user, and then show a 'loading' message in the div where the datagrid resides while the data for it is being fetched. How can I do this using AJAX?

Regards,

Ahmed Zainal

If you put the grid in a panel (Panel A) and have a second panel (Panel B) with a loading gif.

Put a refresh button in with the grid in Panel A. Put both panels in an update panel.

In on page load do not load anything into the grid and set Panel A visibility to false and set Panel B visibility to true.

Create a method that handles the refresh buton on click event server side and add the code to populate the grid in it.

Wire up the update panel to show the loading gif panel when it does a partial page post back and hide it again when the postback response is recieved.

In javascript fire the on click event for the refresh button in the page on load event.

Hope that makes some sense. If not I can try and put some code togethrt for you tonight after work as an example?


Richard,

Thank you for your prompt response! Just one thing. when you say:

"In javascript fire the on click event for the refresh button in the page on load event."

How do I call the refresh on click event in javascript?


For a button declared as:
<asp:ButtonID="Button_Refresh"runat="server"OnClick="Button_Refresh_OnClickEventHandler"/>
JavaScript:
window.onload = init();
function init() {
__doPostBack('<%= Button_Refresh.ClientID %>','');
}
I think that should do it.

Try this http://dotnetslackers.com/articles/ajax/ASPNETAjaxGridAndPager.aspx

Hello

Sorry for the late reply. Internet was down on our lan since this morning!


I found a different method using an ajax timer. I set the interval to 1 millisecond and it calls the timer.tick event straight after the page loads. In the code, I set the enabled property of the timer to false so that it does not keep ticking. I also use an AJAX updateprogress control which displays the loading gif. This works great but I get another problem. I have another AJAX control that uses next and previous buttons to display news articles. If I click on one of these buttons while the datagrid is loading, the datagrid starts loading again but never binds!

Thank you and I really appreciate your help!



Hi

This could be anything, try implementing queuing. Some link below that might help:

Genral tips (Queuing half way down):http://www.codeproject.com/Ajax/aspnetajaxtips.asp

Async calling:http://forums.asp.net/p/1068907/1553801.aspx#1553801

Queuing class:http://www.cmarshall.net/MySoftware/ajax/index.html

Hope one of these helps.

want to pass datatable (.net) to javascript function

hello,

i have a datatable stored at page level (in aspx). i am binding this datatable to gridview object which has a checkbox column for row selection.this table may contain about 500 to 1000 records. when ever i check/uncheck this checkbox, i want to update this bound datatable without posting back to server.is it possible through ajax/javascript ?

pl. provide solution for this asap...

Jayesh Shah

You will have to post back to the server if you want to update the DataTable as that is a server side object. However, you could use a UpdatePanel around the GridView to hide the fact that a full postback is occurring.