Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Web Form
Message
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Titre:
Divers
Thread ID:
01409563
Message ID:
01409592
Vues:
29
The session variable is needed because of the stateless environment I mentioned previously. This variable is what simulates the 'state' of the form's data. Remember, each time you post to the server, you are sending information and receiving information back and that's it. Every post back is a brand new day. That is why page_Load runs each time you post back to the server. It needs to reset everything needed to do what needs to be done. The session variable is stored in your browsers' memory and not at the server.

>To be honest, I'm not clear why that session variable is needed. If the controls are bound to the Entity of the business object and the save is done by the business object, what's the purpose of this datasession except to keep the values around in some form after the posting is made?
>
>>>The btnSave_Click looks like this:
>>>
>>>
>>>  protected void btnSave_Click(object sender, System.EventArgs e)
>>>    {
>>>        DataSet dsOrder = (DataSet)Session["dsOrder"];
>>>
>>>        if (this.Save(this.oOrder, dsOrder, this.oOrder.TableName) ==
>>>           mmSaveDataResult.RulesPassed)
>>>        {
>>>            Response.Redirect("Contact.aspx?Id=" + this.iContactId);
>>>        }
>>>    }
>>>
>>>
>>>When I put a breakpoint after the first line, all the values in the dsOrder dataset are null (or default), which seems to be because it got reset at the bottom of the page_Load method that ran right before this. Do I want it to skip the page_Load when I save?
>>>
>>>Thanks,
>>>
>>>Eric
>>>
>>>
>>You may try to re-set only if Page.IsPostBack = false
>>
>>I believe we had similar code to play with the data set saved in the session (though this is not a good idea at all).
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform