Without reloading the page

M

Mike Levin

Newbie question here.



I'm making a Web database application where I want to get the best
performance possible. I like the way Remote Scripting allows updating of the
dropdown menus without a page reload, and I would like to extensively do
that sort of thing, even for changing the SelectedIndex in a DataGrid. From
my research into ASP.NET, Web Services are the way to do this now, but I
can't find any examples of using Web Services specifically to update
elements on the page without page reloads. Anyone know any resources, or
willing to give some advice?

Mike Levin
 
M

Mike Levin

Hi Bjoern,



Thanks for the reply!



This article talks about migrating existing Remote Scripting code to .NET.
It appears to show how to swap out the old "after-page-load" communication
of Remote Scripting with a Web Service instead. This makes sense to me, but
what if I'm starting from scratch? Should I still use (and adapt) the old
Remote Scripting code for ASP.NET, or isn't there a cleaner way to do it
from scratch instead?



Here is some more background. I have enabled the keyboard arrow keys to move
the SelectedIndex on a DataGrid up and down while displaying a data table on
a Web page. While EXTREMELY cool, it causes a postback and visible page
reload. I'd like to speed this up. Is it possible to write a Web Service
that changes the SelectedIndex on an already displayed DataGrid, so Arrow
Key'ing up and down moves as fast as the local Client/browser can make it
happen? If I do that, is the internal record keeping happening so the
server-side knows it has a new SelectedIndex?



Should I start with the old Remote Scripting stuff as this article suggests?
 
M

Mike Levin

Hi Bjoern,

I'm reading the article. Interestingly, it says...
the client HTML page does not need to be programmed using the .Net
framework.
I'm inclined to think the client HTML page cannot be programmed using the
..Net framework. I think I will investigate "record keeping" on the Client
Side, and pulling down the record keeping and syncing back up on the server
side on special events, like paging (versus just moving the highlight).

I'll look into the webservice.htc. I would consider implementing this
feature so you get blazing non-postback behavior on IE6, and slower but
equivalent behavior in IE5 & others. It's intended for an Extranet audience,
so I don't have control over user platform.
I have never done what you want to do. How did you enable the key navigation
in the datagrid? ;-)

This won't work in when ASP.NET decides not to emit exactly the same
JavaScript links inside the Web Forms (I've got LOTS of experimenting to
do), but here's how I did it...

<script language="javascript" type="text/javascript">
<!--
document.onkeydown = function keyPress(evt)
{
var keyCode =
document.layers ? evt.which :
document.all ? event.keyCode :
document.getElementById ? evt.keyCode : 0;
if (keyCode == 38)
{__doPostBack('ArrowUp','')}
else if (keyCode == 40)
{__doPostBack('ArrowDown','')}
}
//-->
But I don't think it will work what you try to reach.
IMHO the problem you are facing is that if you "submit" the selectedindex by
webservice, the webserver doesn't have an instance of the datagrid :-(
But another question. What will you do on the new selectedindex in your
webapp???

OK, this is tricky. I'm still trying to figure it out myself. Currently,
when I move the SelectedIndex, I update a ViewState value containing the
primary key value so I have it available at all times -- but I probably
don't need that value until something special happens, like paging. If the
movement of the highlighter moves it to the next page, I do a paging event.
But the performance gain I'm trying to get right now is only for moving the
highligher within the same page. I could do this purely with JavaScript,
tweaking the Document Object, but then the server side is totally unaware of
what I've done. I was thinking about Web Services as a way of telling the
Server what I've done, so it can also update the SelectedIndex in its record
keeping. But perhaps the record keeping is only really done in the ViewState
object on the client, and I don't even need to communicate back to the
server (I don't know). Can I alter values in the ViewState object
client-side? Ugh! Everything is so new!
Maybe another possible sollution is to disable the postback and only reload
the page if something special happens on client side.

Yes, this is what I seem to be moving towards. I guess it becomes an issue
of doing "record keeping" client side (JavaScript variables?), and then pull
down the record keeping at special times and re-sync up on the server.

In an ideal world, I'd like ASP.NET to just automatically tweak the Document
Object Model when it can (moving the highlighter) instead of reloading the
entire page. It seems that since all the links it provides in Web Forms are
"javascript:", that it could be done. I'm investigating Web Services because
all Google research leads me to Web Services as an alternative to Remote
Scripting. But perhaps what I really need to research is general management
of values client-side and how to use them server side at special times.

Thanks again for the reply. Any additional feedback is appreciated!

Mike Levin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,150
Latest member
MakersCBDReviews
Top