.Net 2.0 Ajax erases input data

Last post 10-01-2008 11:04 AM by haiwag. 3 replies.

Sort Posts:

  • .Net 2.0 Ajax erases input data

    05-29-2008, 2:16 PM
    • Member
      20 point Member
    • haiwag
    • Member since 09-21-2007, 3:10 PM
    • Posts 9

    We have been experiencing following dilemma after imposing .Net 2.0 Ajax of Microsoft: user inputs some thing in TextBox1, and mouse click on another TextBox2, Ajax round trip started, and user can keep typing in text. However, after Ajax round trip finishes, what user input is lost.

     

    We know there is a Ajax round trip, but as it mentioned as a partial post back, it shouldn't affect another field. So is there a solution?... in spite of any excuse for like: people can always say this is the way .net 2.0 Ajax does.

     

    Hey, Ajax team, I know you've done a lot to make Ajax works as easy as drag-n-drop a script manager, updatePanel and updateProgress. However, like iPhone last year did, its offers hundreds of fancy functions but forgot to put dial-a-phone-call function on, the so called asynchronized Ajax failed to do its job. So please wake up, and make it up. I like the easy way that .Net Ajax delivering. But now i am kicked off by this bug. I have to leave .Net 2.0 Ajax and do my own client - server round trip (you can call it NickAjax), that's a pain. Anyway if you need help, let me know I will fully offer my code for your reference.

    .

    Following are the way I tried and soulution found. Most of all, wonder whether Microsoft has a patch to fix it.

     Solution 1: Using UpdateProgress, it just tells user something is going on, not what I am looking for – I want a solution to solve this problem. (Please see details at following link: http://aspnet.4guysfromrolla.com/articles/050708-1.aspx)

    --With a partial page postback, however, no feedback is provided to the user. Consequently, a user may have instigated a partial page postback, but not realize it if the response is lagging. This may prompt them to click the button (or whatever instigated the partial postback) again, or they may just decry your website as buggy and close their browser, never to return again!

    Solution 2: Using client side javascript, plus cookie, hidden field (Suggested by Jim)

    -- This is the way, traditionally people used before the emergence of .Net technolodgy. At this moment that our Failure Analysis system already piles tonnes of functions on .Net technolodgy, it is a pain to go back. But I am not totally reject this way until we have no way out based on new technology like what Microsofe and or other major leader doing. Sorry Jim for saying this, I know your solution is my bottom line, it may save me from no way out.

     

    Solution 3: Using Javascript to retain lost focus (Suggested by Lei)

    -- It is only working on the lost focus, not the lost data – so just put off for now.

     

    Solution 4: Using Page.PreviousPage object to obtain previous data, so in a second page. (Suggested by Jason)

      -- Made code and tested, and found that, it only works on server side code-behind code, like asp button clicked event; not working on a hyperlink.

      -- Found out the fact that it only works on server side code, not works when click a client side object. I.e. couldn't use a javascript call another page to obtain a valid PreviousPage object. I.e. it is not available for client side code.

      -- Jason is still in faith of this and vowed to work it out, and prove it to me. Thank good man.

     

    Solution 5: DHTML XmlHttp object, it is said that Google is doing this way (not confirmed), I did this a year ago, and pick it up today.

      -- Using XmlHttp object: trying to see whether a second field input is affected by the Ajax round trip like the way .Net 2.0 Ajax does

      -- After testing, my boss Don and I surprisingly found it worked (see Don’s email for the requirements)

      -- Part of Code

          //Creating object of XMLHTTP in IE

          try

          {

                XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");

          }

          catch(e)

          {

                try

                {

                      XmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); // You see Microsoft got its own XmlHttp object! Why its Ajax whips other field input?

                }

                catch(oc)

                {

                      XmlHttp = null;

                }

          }

     

    So a decision was made by Don, that we are to start on XmlHttp DHTML to solve this dilemma. But before abandon .Net 2.0 Ajax, I would like to ask Microsoft .Net team personnel, whether there is a patch to fix this bug (if you deem it is one)? If you do, that’s wonderful, so we can keep on the track of MS direction since we already have been using and enjoying .net technolodgy.

     

    Thanks in advance.


    Hai (Nick) Wang

     Please consider the environment before printing this email.

     

  • Re: .Net 2.0 Ajax erases input data

    05-30-2008, 3:47 PM
    • Member
      20 point Member
    • haiwag
    • Member since 09-21-2007, 3:10 PM
    • Posts 9

    After one day's work on removing .Net Ajax and make all field my own Ajax (NickAjax), I can call it real partial asynchronized postback - a goal that .Net 2.0 Ajax said in their feature, but failed to deliver to real life.

    I have 4 tab pages, there are 10 fields in the first tab. I set a 5 sec delay at ajax server process side, so when I input 10 fields data, a 5 seconds delay is generated each time I finish one field and switch to another one. Amazingly, I can keep typing after previous change goes to server,  --- this is what i meant asynchronize; and everything I typed is well kept after the previous ajax process finished. I.e. I can seamlessly input data, and ajax working behind scene without interference.
     

    So if I type in data for 5 seconds each field, that means after my last typing, I only need another 5 seconds for the last one to go in. The worst case if I type in all 10 fields in no time, I will wait 50 seconds.

     
    But, wait a sec, there is a problem, after I fill in a field, click Save button, my change is not saved. I have to click again, this time it is saved. That sucks - I worked on this times for the last 2 years, no one of my tries work prefectly. I have to change my way on this, I believe there should a way to figure out which button I was clicking on, so after the ajax process, if I check a Save button was clicked, a save process could be launched. So now I am working on this. 

    Filed under: , , ,
  • Re: .Net 2.0 Ajax erases input data

    06-08-2008, 7:45 AM
    • Member
      20 point Member
    • haiwag
    • Member since 09-21-2007, 3:10 PM
    • Posts 9

    What was happening: Last Tuesday (Mon May 26) afternoon, a Whitby Melt Shop user (Cryfor Perform) came to tell Don that FAS is slow. Don tried to explain how a web app works, bacically to say it needs to go back and forth to bring data between client side and server side. None of all of the explain, she just say she is not using it.

     

    We all shocked to feel we have to fix the problem for her. First time to know something bothered some users like her that much.

     

    ... Post 1

    ... Post 2

     

    Okay, okay, okay..

     

    After couple working on a solution on Cookie and PreviousPage:

     

    Cookie turns itself works pretty fine, not amazingly that when you change some thing (change means type in and tab away), data is kept even you get a immediate power off. The most amazing thing about cookie is that it is not teadious and isolated as I originally thought. Actually it presents a good communication between client side and server, i.e. of course you can freely operate it on client side with Javasript, meanwhile, server side server alread does this for you - it stores client cooke for the availabity on server side by using Request.Cookies and Response.Cookie which mean you can read and write whatever anytime you need. But, the broken part came after my enjoyment of it, throught googling I found cookie suggested size is 4096 - 4k, one of my description field is 2000 characters, in my Root Cause tab and Action Plan tab, I have infinite items even in real world say there wouldn't be more than 100 item there, but I at least should prepare a storage of about 1000, i.e. 1000 * 2kB = 2000kB = 2MB, a merely acceptable size.

     

    Told Don about what I have done on DHTML(xmlHttp), cookie - the gain and loss, Don sighed we cannot win?

     

    The way to use a hidden field (or may the same as hidder frame). I knew people tried to ues iframe to keep page state, and ended up with lots of drawbacks, and at an impasse. Personally I always ask self if i am sane to follow this way. It basically says keep another set of object value in current page in hidden fields. Decide go or not to go to another page when user click another page from menu, if there are changes, warn user. So this would save the postback each field changes to keep data in server side session, and when user comes back to the same page, everything is presented there. This way is not wrong itself, but it is not the root, the root is I cannot trigger anything if user clicks a munu item, even I put a javascript before jump to another page, i.e. user clicks a munu to another page, it go there without running anything to process the thing you intent to. I acknowlege that I am noisy and some bit unfounded on this, cause my attitue to it, a bit of racism. But only think this is not the right way, but I didn't rule out it and promised to review it as a way of no other ways out.

     

    Thomas's SessVar was brought into my attention later on. Which is a wisdom hack to intellently use the extra room in a html's head(er). I give you big credit hear, Tom. It does give enough room for me, accodoring to him, for IE about 32MB starting crush. Oooh, that a lot. The only blockade of keeping me on this track is my poor imagination and of course Tom's boundray of his object which give my a hard time of how to access sessvar on my server side code - I am using .Net 2.0 C# code-behind. I leave him a quest to solve my problem. I still keep an eys on it.

     

    Then I turn back to Jason's PreviousPage object - retrieving history data at a second page which gives me much more confusing time - my fun part of getting lost. Quite a long story, i sum our exchange of email dueling.

      --Nick: crossing page depends on at least a asp object which is doing cross page. You can not call from Javascript

      --Jason: javascrpt theForm.action="targetUrl.asp"; theForm.submit(); with solve it

      --Nick: yes it works.

      --Nick: it even better that it trigger and finish server side event before go into a second page. At this time I thought I am totally wrong on insisting on "cannot do crossing page from javascrip".

      --Jason: true, it save the hassle to process preveious page data in all second pages

      --Jason: plus server side code much safer.

      --Nick: breaking finding - client side javascript still need a object (button, menu) which is doing crossing page to do the same. So W3c or whoever backing javascrip does something behind scene to do rescriuting target page for me which beyond me. At this point, I would come a bit back to say "cannot do crossing page from javascrip sololy from a single html object with javascript".

      --Jason: ohoh, I never think of that and will give it a try. That's the strong point of him, never give up, like Hilary Clinton, which is unsoundable powerful at some moment even he or she is lossing his or her final base.

     

    Btw, a funny story Eric W. told me of his link to the earthquake in ChengDu , China . 1938 his mom was there and took a photo by holding a baby panda in some ChengDu Zoo. I ask him where he was jealous, then we laughed. That time he was not born to be jealous yet.

     

    That is why i was so pethetic when I read somebody's complaining about the shame in deverlping .net web app. My echo is when you spent a lot time to solve a existing problem for Microsoft's newbeeness, then they doing something stealth trying to solve the problem pretending you don't know, and ironically the fix cause new problems. Sign, I wouln't be doing better if I were Microsoft, the only problem to them is they got a name of Microsoft while most of us not, and we pay them. At least they've got better control of tiers of objects which we don't, which I can say i would try to do better - I wonder whether team of MS knows the right way to follow, maybe they are lost too as me.

     

    Up to now, if you can get tom's full name, and post response here (asp.net) under this post, the first 3 guys will get a check with some dollars. Don't forget leave your address to my email ( haiwag@yahoo.com ) so I can mail it to you. If you know to use Google to search, you are prolly smarter than me.

     

    Now I am going to do is put dummy crossing page object, and then doing else things to see whether it kills.

     

    You know what, it kills. By putting a crossing page target dummy in a page, I can do javascript page crossing like theForm.action = linkOfNextPage; theForm.submit(); The target dummy looks like the following, it would bring up / download _EVENTTARGET and _EVENTARGUMENT behind scene, again I hate what they do stealthly like this out of my blue. I should put it into a ancester, and make it invisible, and it should work of course. It is too simple, but I will tell you whether it works.

    <asp:Button ID="ButtonCrossingPage" runat="server" PostBackUrl="~/CrossingPageDummyTarget.aspx" Text="" Height="1" Width="1" /> <!-- 03350_ajax_submit -->

     

    No, cannot set it invisible, it has to be shown in page. Bucause it wouldn't be rendered if it is invisible. It has to have a smallest size, 1x1. To check whether user can esaily click or tab through on it and trigger it to goto the target dummy page, I couln't. I am not rule the possibility of that, it is acceptable for me for sure at this moment.

     

    I added it after my page footer, so every page which inherits gets it, like

        // add crossing page target dummy

        //<asp:Button ID="ButtonCrossingPage" runat="server" PostBackUrl="~/CrossingPageDummyTarget.aspx" Text="" Height="10" Width="10" /> <!-- 03350_ajax_submit -->

        System.Web.UI.WebControls.Button ButtonCrossingPage = new Button();

        ButtonCrossingPage.ID = "ButtonCrossingPage";

        ButtonCrossingPage.Style.Add("RUNAT", "SERVER");

        ButtonCrossingPage.PostBackUrl = "~/CrossingPageDummyTarget.aspx"; //no such thing at all because it is a target dummy

        ButtonCrossingPage.Text = "";

        ButtonCrossingPage.Height = System.Web.UI.WebControls.Unit.Pixel(1);

        ButtonCrossingPage.Width = System.Web.UI.WebControls.Unit.Pixel(1);

        Form1.Controls.AddAt(Form1.Controls.Count, ButtonCrossingPage);

     

    I run the web app, every page is reached smoothly, all server side (of course client side) are triggered and finished before getting crossed, the way Ajax tried but failed. Most of all, I do not have unnecessary postback. My data in every fields got presisted, they are there when I have to go to other page to check something and come back. Of course, after 2 hours timeout, it is saved to a file and show me all my last status with a warning "you have unsaved data.". This is my app, I can have a sweet sleep again. But I have to do more test.

     

    Hai (Nick) Wang

  • Re: .Net 2.0 Ajax erases input data

    10-01-2008, 11:04 AM
    Answer
    • Member
      20 point Member
    • haiwag
    • Member since 09-21-2007, 3:10 PM
    • Posts 9

    - Summary of 04760 - FA Performance Optimization:
        - Make Server side, client side process communicatable: no matter which side need current newest state, the other side had it ready and the requester can get it.
        - Multi side data sharable including server side c# code, client side javascript, and ajax partial postback processing
        - On server side, it has two aspect of client side data obtain
            - In postback, which has no object been posted back yet, cannot get data like this.FindControl(controlName). This case, client data is obtained through hidden field
                - like this.FindControl(hiddenFieldName), or Request.form(0).hiddenFieldName
                - This is used to obtain some key data of client side, like which tab page currently on, any data changed (IsChanged), etc.
                - For other data, the changed data is remain on client page object field, which is also unaffordable to be lost
                    - any time once needed, a _bringInNewestChange() function will be called on server event code to bring in all client data (like discussed after)
            - In butten event, or field changed event, obtain client side data like
                - ((TextBox)this.FindControl(controlName).Text
                - Which is used to obtain the newest client state, it is used frequently whenever there is a need on server side.
        - Ajax partial postback:
            - because the nature of it, there is no page refresh, so we do not have to bring in all newest changes. So just bring in necessary ones
            - It could be hidden field or get from Request object
        - Conditional postback from client side javascript
            - So case, like conditionally sending email, or no saving right user filled in date for the field which was appointed to him or her, a server side emailing or database saving may happen
            - Use client side postback, like
            - document.forms(0).hfPBName.value='NoSaveUsr_' + lsObjectField; //hfPBName: a hidden field to indicate with object field is posting back, 'NoSaveUsr_' tells what to do on server side
            - document.forms(0).submit(); // post it back from client side
        - So case we need to click / trigger server side event from client side
            - E.g. cases: need to do a page refresh from client side, or to accept changes, where there are buttons on page doing this with server side code behind to process them.
            - Under these cases, we can borrow them instead of re-write.
            - Using __doPostBack('FANavigation1:ibAcptChng', ''); // this client side code will trigger FANavigation1 user object's accept change button       
            - So a little complex situation on my case, I need to trigger a recurring issue search when afte user input description information
                - Not only on sever side to grab all new changes, but also to see what to do, so a postback parameter is used
                - __doPostBack('FANavigation1:ibAcptChng', 'LaunchRecSearchPage');
        - Anyway, .net web application development multi side / layer programming is a trade-off twisting of your mindpower. It's a pain, however, if you use it freely, you will fill the release.
     

Page 1 of 1 (4 items)