473,465 Members | 1,458 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Using Atlas UpdatePanels with GridView sorting?

Hi all,

I'm a newbie to Atlas (and recently ASP.NET) after coming from a long
Java background, also have done quite a bit with an Ajax.NET/ASP.NET
1.1 project, but it was basically all javascript, nothing really having
to do with ASP.NET...

I'm attempting to put together an application that consists of several
GridView controls each bound to some xml data. Each table exists in
its own update panel. The two effects I'm going for are:

1. Sorts on the GridView should be handled through a PartialLoad, so
nothing else on the page changes (ideally that HTML wouldn't even be
created on the server side, especially if there is heavy processing
involved in recreating some of the tables).
2. I'd initially like the page to load blank (meaning no GridViews),
then have each GridView come down individually in its own partial load
call, thereby popping up on the screen as they arrive (this is because
the retrieval of data underlying some tables may be a very long
processing call, 1 minute in some cases. Other tables should be
available on the page even while that one is still loading server
side).

So far I've been using UpdatePanels to implement this functionality and
have gotten some good results without truly understanding the lifecycle
of a PartialLoad request indepth (both client and server side).
However there are a few stumbling blocks that I've come across, as well
as questions about how Atlas partial loads are really performing their
job. Any advice that this group can provide would be greatly
appreciated.

I've created a small simulation to post here. We have one aspx page,
with two GridViews, each within it's own UpdatePanel:

<form id="form1" runat="server">
<atlas:ScriptManager ID="ScriptManager1" runat="server" />
<atlas:UpdatePanel ID="panel1" runat="server"
Mode="Conditional">
<ContentTemplate>
<asp:GridView ID="table1" runat="server"
AllowSorting="true" OnSorting="SortTable">
</asp:GridView>
</ContentTemplate>
</atlas:UpdatePanel>
<atlas:UpdatePanel ID="panel2" runat="server"
Mode="Conditional">
<ContentTemplate>
<asp:GridView ID="table2" runat="server"
AllowSorting="true" OnSorting="SortTable">
</asp:GridView>
</ContentTemplate>
</atlas:UpdatePanel>
</form>
Obviously there is a ScriptManager on the page as well, with
EnablePartialRendering set to true. Next, in the code behind, I just
create a few lists of dummy objects to act as the model data for these
tables. I'm binding the GridView directly to these lists. I added an
event handler to handle the GridView sort calls when clicking on the
table headers, but haven't implemented the sorting yet (it's not
important for this example):

protected void Page_Load(object sender, EventArgs e)
{
// set up model for first two tables
Table1Model obj1 = new Table1Model("string", "another string");
Table1Model obj2 = new Table1Model("more strings", "and even
more!");

Table2Model obj3 = new Table2Model("A", "B", "C");
Table2Model obj4 = new Table2Model("D", "E", "F");

IList<Table1Modeltable1Datasource = new List<Table1Model>();
table1Datasource.Add(obj1);
table1Datasource.Add(obj2);

IList<Table2Modeltable2Datasource = new List<Table2Model>();
table2Datasource.Add(obj3);
table2Datasource.Add(obj4);

table1.DataSource = table1Datasource;
table2.DataSource = table2Datasource;

table1.DataBind();
table2.DataBind();

}


So the two things I'd like to accomplish go hand in hand here. One is
that I'd like to get the Page_Load to the point where only the GridView
that is being sorted needs to be rebuilt (ie. binding it to the model
again and then having ASP.NET render that HTML). Logically that should
be fine because the only HTML that should get swapped out on the
browser side is the HTML for that particular table. I can do that by
detecting which table fired the sort action using the parameter that
the Atlas PartialLoad seems to put in the Request, __EVENTTARGET. Thus
Page_Load becomes this:
if (!IsPostBack)
{
... create model like above for both tables on initial page
load...
}
else
{

string eventTarget = Request.Params[__EVENTTARGET]; //
figure out which table asked for the sort.
if (eventTarget.Equals("table1"))
{
Table1Model obj1 = new Table1Model("string", "another
string");
Table1Model obj2 = new Table1Model("more strings", "and
even more!");
IList<Table1Modeltable1Datasource = new
List<Table1Model>();
table1Datasource.Add(obj1);
table1Datasource.Add(obj2);
table1.DataSource = table1Datasource;
table1.DataBind();
}
else if (eventTarget.Equals("table2"))
{
Table2Model obj3 = new Table2Model("A", "B", "C");
Table2Model obj4 = new Table2Model("D", "E", "F");
IList<Table2Modeltable2Datasource = new
List<Table2Model>();
table2Datasource.Add(obj3);
table2Datasource.Add(obj4);
table2.DataSource = table2Datasource;
table2.DataBind();
}
}

This works very well actually (please forgive the code duplication
here, just a silly example).

Now I need to take this to the final step. On the initial page load, I
won't do any databinding at all. The HTML that is delivered to the
browser is just the empty <divtabs for each UpdatePanel. However,
how can I actually trigger the PartialLoad to happen from the browser,
one it has the initial blank page? It must be some custom javascript
that I'll execute in the page load which will essentially make
PartialLoad requests for each of the empty <divtags currently
existing in the page on the browser, and in those Page_Loads I'll
detect that it is a postback, figure out which table needs to load (it
won't be __EVENTARGET in this first case, it'll have to be a parameter
I provide, like the updatePanel name) and then databind just that one
to the model that gets computed (like above). How to execute those
though? Looking at the HTML rendered in the browser when I do render
all the tables at the start, I notice these important bits:

<script type="text/javascript">
<!--
var theForm = document.forms['form1'];
if (!theForm) {
theForm = document.form1;
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
// -->
</script>

and <a
href="javascript:__doPostBack('table2','Sort$Field 4')">Field4</afor
the column headers of every table. When doing theForm.submit(), why
does the browser know to execute this in the background as a partial
load, instead of doing a regular postback in which the user loses the
page and the entire page refreshes? I'm very unclear about that, if I
knew the answer, I could then write my own javascript to do the behind
the scenes postbacks for every table.

Or is there some way that Atlas provides to do this already by setting
up the appropriate properties on the ScriptManager or UpdatePanels?
Also, I do see a lot when researching update panels about providing
triggers, but I don't know how that factors in with triggering sort
events. Does Atlas recognize that the GridView is inside an
UpdatePanel, and create the necessary triggers? Or is this somehow
bypassing that functionality entirely?

Also, is there a way to debug through the client side javascript code
that makes up the Atlas client libraries? Where does one even find
this source, it is hidden within the Atlas.dll?
Thanks for any input!
Regards,

Jason

Oct 11 '06 #1
1 3510
If you don't get an answer here you can try the Atlas (now renammed to
ASP.NET AJAX) forum at asp.net:

http://forums.asp.net/default.aspx?GroupID=34

Oct 12 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: ck388 | last post by:
For some reason when I enable the callback feature of the gridview I still get a page refresh, that is it seems like there is a postback that occurs, not a callback which is just supposed to update...
1
by: needin4mation | last post by:
Hi, I have a gridview and a detailsview. Is it possible to select a row in the gridview, not have a postback, and instead have a detailsview populate based upon the gridview - in Atlas, no...
8
by: Chris | last post by:
Hi, I can't seem to find any info on calling a webservice with atlas and populating a gridview with the results. All the doc shows on the atlas website is alert. Who would want to alert? Please...
3
by: Piotrek | last post by:
Hi all. I am creating a web site, in which I would like to use Atlas. I created an user control (Test1), in which there is a DropDownList with some values. I set AutoPostbackProperty of this...
1
by: majorone | last post by:
hello, i am new to atlas and trying to use it on my user control. but after i implemented the following code, i have got a error in yellow page: "MaintainScrollPostition is not supported on pages...
3
by: Robert Scheer | last post by:
Hi. I think I have some conceptual questions here. I have an asp.net web application up and running and now I intend to use Atlas on some of my pages. I have read that after installing Atlas, I...
1
by: tcc.se7en | last post by:
Hi -- I have an ASP.NET web app that I just converted to use a Master Page for common content (banner and nav). I also just updated my version of the MS Ajax framework to the latest one (and had...
0
by: Eduardo Klein | last post by:
Hi all I'm trying to convert an application that uses Atlas to use Ajax RC1. The ScriptManager is placed in the MasterPage and I have a Form with some UpdatePanels and a...
1
by: Oriane | last post by:
Hi, I've written a Ajax enabled application with the Atlas .NET 1.0 extension and ASP.Net 2.0. I've put 2 UpdatePanels on a unique page with 1 timer on the second panel. This timer refresh a...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.