Persisting Design-time generated value

Discussion in 'ASP .Net Building Controls' started by J.Marsch, Oct 7, 2003.

  1. J.Marsch

    J.Marsch Guest

    I want to add a property to a control that will contain a GUID.

    This GUID. Should be generated at design time, when the control is dropped
    onto a WebForm. After the control has been dropped, the GUID should always
    be of the same value. The problem is, that I cannot seem to get this GUID
    value to be saved to the WebForm HTML.

    I was able to accomplish this very easily with winforms:
    public string ControlId
    {
    get
    {
    if(this._ControlId == null)
    this._ControlId = System.Guid.NewGuid().ToString("N");
    return this._ControlId;
    }
    set
    {
    this._ControlId = value;
    }
    }

    That was all it took, because the Winform Designer would add code in
    InitializeControl that re-set the ControlId to it's original value (for a
    moment, it will have a new value, and then is reset to the original)

    This doesn't seem to work with the WebForms designer. If I use this same
    code, the value that is generated at design time is never persisted
    (although it does appear in the Properties Window).

    If I manually set the property at design time (with the Property Window),
    whatever I typed in _is_ persisted as an Attribute in the HTML. How can I
    guarantee that this automatically generated?
    J.Marsch, Oct 7, 2003
    #1
    1. Advertising

  2. J.Marsch

    Mike Clay Guest

    Hi Jeremy,

    My name is Mike with the ASP.NET Developer Support team.
    I will be looking into this issue for you.
    I will post a reply as soon as I find out something.

    Mike Clay, MCSD
    ASP.NET Support


    This posting is provided "AS IS" with no warranties, and confers no rights.
    © 2002 Microsoft Corporation. All rights reserved.
    Mike Clay, Oct 9, 2003
    #2
    1. Advertising

  3. J.Marsch

    Mike Clay Guest

    Hi Jeremey,

    You will need to set the PersistenceModeAttribute. Here is a link that
    explains further:

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
    frlrfSystemWebUIPersistChildrenAttributeClassPersistTopic.asp

    Mike Clay, MCSD
    Beta Technical Support


    This posting is provided "AS IS" with no warranties, and confers no rights.
    © 2002 Microsoft Corporation. All rights reserved.
    Mike Clay, Oct 13, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Allan Ebdrup
    Replies:
    11
    Views:
    645
    Walter Wang [MSFT]
    Jul 26, 2007
  2. Steve Barker

    Properties not persisting at design time.

    Steve Barker, Jan 22, 2004, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    144
    Steve Barker
    Jan 22, 2004
  3. cpnet

    Persisting control properties at design time

    cpnet, Apr 19, 2004, in forum: ASP .Net Building Controls
    Replies:
    15
    Views:
    268
    Jeffrey Tan[MSFT]
    May 10, 2004
  4. jebecker@_NO_SPAM_.pointroll.com

    Issues Persisting Design time changes to page source

    jebecker@_NO_SPAM_.pointroll.com, Jul 13, 2006, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    103
    jebecker@_NO_SPAM_.pointroll.com
    Jul 14, 2006
  5. JesperA

    Problem persisting asp.net 2.0 property in design-time

    JesperA, Oct 17, 2006, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    120
    Brennan Stehling
    Oct 18, 2006
Loading...

Share This Page