Datagrid and clientside callback events

Discussion in 'ASP .Net Datagrid Control' started by Dmitry, Sep 16, 2004.

  1. Dmitry

    Dmitry Guest

    Hi All,

    I've been looking at clientside callbacks as a way to update parts of
    a page without a postback.

    Is there a way of rebinding a datagrid on the client. The scenario
    would be something like this:

    A work queue is displayed on a page using a datagrid
    Items are added to the underlying data source by other components in
    the system
    A javascript function executes every n seconds and discovers new items
    for the queue
    the datagrid updates, but importantly, the page does not postback

    If we can update the datagrid without a postback it means a user can
    be filling out a form on the page, but also gets immediate notice that
    new items are in the queue.

    As far as I can tell a datarid is just rendered html by the time it
    gets to a browser, so it can't be manipulated and rebound from the
    client.

    In contrast, the treeview client behaviour is a clientside object
    which binds to an xml data source and can be rebound through client
    script.

    So it appears I'd need to create something similar to mimick a
    datagrid.

    Does anyone have any thoughts?

    Thanks
     
    Dmitry, Sep 16, 2004
    #1
    1. Advertisements

  2. In web technology there is no such a thing as refresh without postback. Any
    refresh is originated on the client and the server gets the refresh request
    via postback. And there is no such a thing a refreshing only part of a page.
    What you can do is to put the grid in a separate iframe and refresh that
    iframe only.

    Eliyahu
     
    Eliyahu Goldin, Sep 19, 2004
    #2
    1. Advertisements

  3. Dmitry

    Dmitry Guest

    Have a look at:
    http://www.dotnetjunkies.com/Tutorial/E80EC96F-1C32-4855-85AE-9E30EECF13D7.dcik

    it describes asp.net 2.0's client callback implementation which in
    turn is built on the msxml.xmlhttp object which has been around quite
    a while. It lets you make calls to server side methods from client
    code without posting back the page. So now you know there is a way to
    refresh only part of a page ;o)
     
    Dmitry, Sep 20, 2004
    #3
  4. No, I still don't know. ASP.NET 2.0 has not been released yet and can't be
    relied on for commercial product development. Beta is good for playing
    around and for learning for future. That's why you won't find many
    2.0-related threads in the newsgroups. BTW, you original message doesn't
    mention 2.0.

    As far as I am aware, solutions based on xmlhttp are hassle to implement in
    asp.net. Also they are limited to IE5. Currently, it is not a practical
    approach unless you have a very special need for it. Note, that ASP.NET 2.0
    shields the developers from working directly with xmlhttp.

    Eliyahu
     
    Eliyahu Goldin, Sep 20, 2004
    #4
  5. Dmitry

    Dmitry Guest

    Agreed 2.0 is only in Beta and I didn't originally mention it.

    I disagree that its a hassle to implement - you can get a response
    back in three lines of javascript. Another approach, using wininet is
    admittedly more fiddly.

    I also agree that its limited to ie5+ - but that's another thread ;o)

    It may be the case that its usage is not widespread at the moment and
    so could represent a very special need. However I think its
    interesting that ms have chosen to include it in v2.0 of asp.net
    because they perceive there being a demand for it.

    Regards
     
    Dmitry, Sep 21, 2004
    #5
  6. I disagree that its a hassle to implement - you can get a response
    May be, I didn't try myself.
    100% agree. Demand is for sure there. Waiting for the release...
     
    Eliyahu Goldin, Sep 21, 2004
    #6
  7. Dmitry

    stephg Guest

    Hi Guys,

    let me get on bord with this. I am also deperately looking for re-drawing
    only a part of an HTML page like a datagrid and also came accross
    ICallBackEventHandler.
    Currently I am working with iFrames and am refreshing the iFrame pages. But
    as you probably know this is very ugly since the screen flickering drives a
    user crazy.
    So, I believe that ICallBackEventHandler could be a solution. I took a deep
    drive into it, but seem not to manage to implement it properly.
    Dmitry, did you manage to update your datagrid by using ICallBackEventHandler?
    If so I would appreciate if you can give me some snippet of your code how to
    facilitate this.
    cheers
     
    stephg, Sep 22, 2004
    #7
  8. There is a superb solution for that:
    http://www.thycotic.com/dotnet_remotescripting_client.html

    You don't read to do the plubmbing hassle associated with the xmlhttprequest
    and now it is browser portable. A beautiful solution: just return a C# data
    type from the server and get it converted into javascript type on the
    client -- has both synchronous and asynchronous versions.
     
    Shahid Siddiqui, Sep 23, 2004
    #8
  9. Dmitry

    Dmitry Guest

    I am also deperately looking for re-drawing

    Stephg,

    Well, my original query was as to whether there was a way to work with
    the datagrid on the client, but I'm fairly sure there isn't - as far
    as the dom is concerned what you see as a datagrid is just a bunch of
    html.

    The internet explorer treeview clientside behaviour IS an object and
    has properties and methods that can be called, so using
    ICallBackEventHandler it would be possible to add/retrieve data
    without the page flicker.

    I can mail you some code showing how to make a request without posting
    back - though this is asp.net 1.0 and ICallBackEventHandler is not
    available - but the code does the same thing that
    ICallBackEventHandler does under the hood.

    That will gives you the ability to communicate with the server, but
    still no datagrid.

    For the datagrid....I'm thinking about creating a javascript object
    that binds to html. It would be an html table that uses xml as a
    datasource and has methods to add and remove rows. Nothing
    particularly fancy, but i've not got time to do it right now.

    Why not have a go at rolling your own? Make it an asp.net user/server
    control and you can add server side functionality too.
     
    Dmitry, Sep 23, 2004
    #9
  10. Dmitry

    stephg Guest

    Shahid Siddiqui,

    thanks for this post. However, it does not seem to fit into my requirements
    since remote scripting only accepts strings as input. My datagrids and other
    fields on the page are populated by webservices. These webservices expect xml
    objects as input and return XmlNodes.
    But maby I can use the one or the other part of this Thycotic thing in my
    project
    Thanks
     
    stephg, Sep 23, 2004
    #10
  11. Dmitry

    stephg Guest

    Thanks Dmitry.
    In deed I would be interested in this code. If you could send it to my
    temporary address at .
    What I am after is to consume my web service every 10 seconds or so that
    expects an XmlDocument object as input and returns an XmlNode object.
    I want to display this updated data on the page.
    Thanks a lot
     
    stephg, Sep 23, 2004
    #11
  12. May the raw xmlHttpRequest help you, I haven't explored it but it supports
    XML -- anything compatible.......Moreover for manipulating the grid on the
    client side, the only thing you have is JavaScript as I am doing in my
    project but the problem is that if you want to exploit the viewstate on the
    server side, how the changes would be reflected in that?
    If you don't need viewstate of the grid, its ok otherwise what I guess, you
    would have to add some customized code on the server side.
     
    Shahid Siddiqui, Sep 24, 2004
    #12
  13. Dmitry

    Dmitry Guest

    I've sent some code to that address. BTW - for webservices you might
    try to track down webservice.htc which was floating around on
    microsoft's website
     
    Dmitry, Sep 24, 2004
    #13
  14. Dmitry

    Dmitry Guest

    This is an iFrames solution by the looks of the msrsclient.js file.
    stephg said he was originally using iFrames but didn't like the screen
    flicker. The difference with this is that the iFrame is hidden and
    used as a container to return values. Nice cross browser approach.
     
    Dmitry, Sep 24, 2004
    #14
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.