p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Professional Web Parts and Custom Controls ASP.NET ISBN: 0-7645-7860-X (http://p2p.wrox.com/forumdisplay.php?f=225)
-   -   Page.Unload Personalization Saving (http://p2p.wrox.com/showthread.php?t=37269)

wewald January 16th, 2006 04:56 PM

Page.Unload Personalization Saving
 
Great book Peter.

On p360 between steps 5 and 6 identifies that "the user performs some personalization activities" and "the page's data is posted back to the server".

My question is how can I trigger this (it already saves when I logout, just not when I change pages)? I was hoping I could do it via a line or two of code on the Page.Unload or similar.

Walter

(I've included the simple class code in case that helps)

_________

Imports System
Imports System.Web
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts

Partial Class Controls_CountyState_Zip
    Inherits System.Web.UI.UserControl
    Private ZipCodeSave As String
    <Personalizable(), WebBrowsable()> _
    Property ZipCodeSave1() As String
        Get
            Return ZipCode.Text
        End Get
        Set(ByVal value As String)
            ZipCode.Text = value
        End Set
    End Property

    Protected Overrides Sub CreateChildControls()
        Dim Textbox1 As New TextBox()
        Textbox1.Text = ZipCode.Text
        Controls.Add(Textbox1)
    End Sub
End Class


peter.vogel@phvis.com January 16th, 2006 08:36 PM

Hmmmmm.... I'm not sure that I understand what you're trying to do (which pretty much ensures that I won't provide a useful answer).

It is true that because you perform the personalization actions in the browser, your latest changes can't be saved until you post your data back to the server where ASP.NET can process your changes. Talking about logging out: If you use the ASP.NET logout option through the LoginStatus control you will get your page posted back to the server for processing and give ASP.NET's personalization code a chance to run.
   However, and I may be out to lunch here, as soon as you finish any WebPart personalization action that I can think of, the page automatically posts back to the server. This is why I suspect that I'm missing your point.

Are you asking if there's any way to trigger a postback to the server from client-side code? If so, the answer is yes--the question is just what client-side event you want to attach the client-side code to. But because I'm tied up thinking that the page will postback anyway, I'm not sure why you'd want to add the client-side code.

When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.

- Sherlock Holmes, as recorded by Sir A. C. Doyle in "The Blanched Soldier"

wewald January 17th, 2006 09:15 AM

Sorry Peter, here's some clarity.

I built a custom control that has a text box. When I change that text, it does not trigger a post-back. So, when I change the text and leave that page (unless I leave by hitting "logout" which uses the .Net 2.0 login/logout control) the text is not saved.




peter.vogel@phvis.com January 17th, 2006 10:38 AM

I get it. Thanks for the clarification.

Would inserting the autopostback code described on page 88 (and on) do the job for you? It should enable you to add the JavaScript code to trigger a postback on a client-side event (in this case, the onblur event of your textbox sounds like the right choice).

If you are going this route, I'd recommend implementing the AutoPostback property so that a developer using your control can turn this option on or off.

When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.

- Sherlock Holmes, as recorded by Sir A. C. Doyle in "The Blanched Soldier"


All times are GMT -4. The time now is 10:18 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.