Welcome Guest Search | Active Topics | Members | Log In | Register

Web Parts Instances Options · View
JJ
Posted: Wednesday, October 03, 2007 7:04:12 PM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 03/10/2007 19:04:12
Date: Wed, 3 Oct 2007 18:04:12 +0100

I'm newish to web parts:

Say for example I create a web part from a control that displays some text
on a web page. The control would allow some text, which is stored in an sql
database, to be edited. The user could in theory add several instances of
this web part to a page, and each instance needs to display its unique text
as stored in the corresponding record in the database.

In order to achieve this I would imagine I need to tie a web part instance
to some sort of unique identifier. How would I do this? In other words, how
is it possible for different instances of the same web part to refer to
unique records?

Please tell me if I'm not making myself clear.
JJ


JJ
Posted: Wednesday, October 03, 2007 7:44:03 PM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 03/10/2007 19:44:03
Date: Wed, 3 Oct 2007 18:44:03 +0100

Ok I think, or rather hope, I've gone some way to answering my own question.

I've used the controls UniqueID property to establish a connection between
the instance an a unique record in the database. From my very limited tests,
this UniqueID property doesn't seem to change if you change the position of
the web part on the page, or if you add others around it, or change the
order.

My next quesiton is, is this uniqueID unique throughout the entire site, or
do I need to add some other unique information to it (like the path to the
current page, for instance)? I suspect I do, but would appreciate some
advice here...

JJ


"JJ" <abc@xyz.com> wrote in message
news:O9U2W9dBIHA.4880@TK2MSFTNGP03.phx.gbl...
> I'm newish to web parts:
>
> Say for example I create a web part from a control that displays some text
> on a web page. The control would allow some text, which is stored in an
> sql database, to be edited. The user could in theory add several instances
> of this web part to a page, and each instance needs to display its unique
> text as stored in the corresponding record in the database.
>
> In order to achieve this I would imagine I need to tie a web part instance
> to some sort of unique identifier. How would I do this? In other words,
> how is it possible for different instances of the same web part to refer
> to unique records?
>
> Please tell me if I'm not making myself clear.
> JJ
>


Steven Cheng[MSFT]
Posted: Thursday, October 04, 2007 2:44:21 AM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 04/10/2007 02:44:21
Date: Thu, 04 Oct 2007 02:44:21 GMT

Hi JJ,

To answer your question first, Yes, UniqueID is a unique identifer for a
given control, but this is only guaranteed at page level(for this web form
page), it help make sure that on the client-side rendered html form, every
control won't have duplicated client identifiers.

for your scenario, you just need to make sure each webpart control(of your
custom one) instance has its own unique value and this value need to be
automatically generated, correct? If so,I think you can consider the
following approaches:

1) Use the Page's "GetHashCode" to get its instance identifier and then
combine it with your control's uniqueID(or also HashCode value) to generate
an new identifer.

2) You can use the current timestamp and combine your control's ID to
generate an identifer

How do you think?

If there is anything I misunderstood, please feel free to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================


This posting is provided "AS IS" with no warranties, and confers no rights.


>From: "JJ" <abc@xyz.com>
>References: <O9U2W9dBIHA.4880@TK2MSFTNGP03.phx.gbl>
>Subject: Re: Web Parts Instances
>Date: Wed, 3 Oct 2007 18:44:03 +0100
>Ok I think, or rather hope, I've gone some way to answering my own
question.
>
>I've used the controls UniqueID property to establish a connection between
>the instance an a unique record in the database. From my very limited
tests,
>this UniqueID property doesn't seem to change if you change the position
of
>the web part on the page, or if you add others around it, or change the
>order.
>
>My next quesiton is, is this uniqueID unique throughout the entire site,
or
>do I need to add some other unique information to it (like the path to the
>current page, for instance)? I suspect I do, but would appreciate some
>advice here...
>
>JJ
>
>
>"JJ" <abc@xyz.com> wrote in message
>news:O9U2W9dBIHA.4880@TK2MSFTNGP03.phx.gbl...
>> I'm newish to web parts:
>>
>> Say for example I create a web part from a control that displays some
text
>> on a web page. The control would allow some text, which is stored in an
>> sql database, to be edited. The user could in theory add several
instances
>> of this web part to a page, and each instance needs to display its
unique
>> text as stored in the corresponding record in the database.
>>
>> In order to achieve this I would imagine I need to tie a web part
instance
>> to some sort of unique identifier. How would I do this? In other words,
>> how is it possible for different instances of the same web part to refer
>> to unique records?
>>
>> Please tell me if I'm not making myself clear.
>> JJ
>>
>
>
>

JJ
Posted: Thursday, October 04, 2007 11:05:46 AM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 04/10/2007 11:05:46
Date: Thu, 4 Oct 2007 10:05:46 +0100

Hi Steven.

Your answer leads me onto some more questions:

1) Using the method of combining the pages 'GetHashCode' with the controls
UniqueID:
I can see how this would work - I could recalculate this value each time a
control loads and then use this as a key to find the corresponding database
record. My question is, however, does this GetHashCode algorythm change when
the framework changes (I understand that .net 1.1 was different to .net
2.0)? Such a change would break the link between control and database
record - a problem I belive some others had when upgrading to .net 2.0.

2) Using the current timestamp + control UniqueID:
I can see how this would generate a new unique identifier each time the
control was created - but how would I 'store' the original value in order to
use it next time as a key to look up the database record? Surely it would
change each time the control was loaded?

There must be a technique here that is being used in personalization - i.e.
the personalization 'system' knows which control/webpart is which and where
its located on the page. Unfortunately, the tables do not reveal exactly how
this is done.

I look forward to your (or others) response,
Many thanks,
JJ


"Steven Cheng[MSFT]" <stcheng@online.microsoft.com> wrote in message
news:RBn78BjBIHA.5204@TK2MSFTNGHUB02.phx.gbl...
> Hi JJ,
>
> To answer your question first, Yes, UniqueID is a unique identifer for a
> given control, but this is only guaranteed at page level(for this web form
> page), it help make sure that on the client-side rendered html form, every
> control won't have duplicated client identifiers.
>
> for your scenario, you just need to make sure each webpart control(of your
> custom one) instance has its own unique value and this value need to be
> automatically generated, correct? If so,I think you can consider the
> following approaches:
>
> 1) Use the Page's "GetHashCode" to get its instance identifier and then
> combine it with your control's uniqueID(or also HashCode value) to
> generate
> an new identifer.
>
> 2) You can use the current timestamp and combine your control's ID to
> generate an identifer
>
> How do you think?
>
> If there is anything I misunderstood, please feel free to post here.
>
> Sincerely,
>
> Steven Cheng
>
> Microsoft MSDN Online Support Lead
>
>
>
> ==================================================
>
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
> ications.
>
>
>
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 1 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions or complex
> project analysis and dump analysis issues. Issues of this nature are best
> handled working with a dedicated Microsoft Support Engineer by contacting
> Microsoft Customer Support Services (CSS) at
> http://msdn.microsoft.com/subscriptions/support/default.aspx.
>
> ==================================================
>
>
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
> --------------------
>>From: "JJ" <abc@xyz.com>
>>References: <O9U2W9dBIHA.4880@TK2MSFTNGP03.phx.gbl>
>>Subject: Re: Web Parts Instances
>>Date: Wed, 3 Oct 2007 18:44:03 +0100
>>Ok I think, or rather hope, I've gone some way to answering my own
> question.
>>
>>I've used the controls UniqueID property to establish a connection between
>>the instance an a unique record in the database. From my very limited
> tests,
>>this UniqueID property doesn't seem to change if you change the position
> of
>>the web part on the page, or if you add others around it, or change the
>>order.
>>
>>My next quesiton is, is this uniqueID unique throughout the entire site,
> or
>>do I need to add some other unique information to it (like the path to the
>>current page, for instance)? I suspect I do, but would appreciate some
>>advice here...
>>
>>JJ
>>
>>
>>"JJ" <abc@xyz.com> wrote in message
>>news:O9U2W9dBIHA.4880@TK2MSFTNGP03.phx.gbl...
>>> I'm newish to web parts:
>>>
>>> Say for example I create a web part from a control that displays some
> text
>>> on a web page. The control would allow some text, which is stored in an
>>> sql database, to be edited. The user could in theory add several
> instances
>>> of this web part to a page, and each instance needs to display its
> unique
>>> text as stored in the corresponding record in the database.
>>>
>>> In order to achieve this I would imagine I need to tie a web part
> instance
>>> to some sort of unique identifier. How would I do this? In other words,
>>> how is it possible for different instances of the same web part to refer
>>> to unique records?
>>>
>>> Please tell me if I'm not making myself clear.
>>> JJ
>>>
>>
>>
>>
>


JJ
Posted: Thursday, October 04, 2007 11:19:40 AM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 04/10/2007 11:19:40
Date: Thu, 4 Oct 2007 10:19:40 +0100

Another thougth about the GetHashCode + Unique ID method:
In this scenario I am building a limited CMS system. It is possible
therefore that the URL of the page may change if its location in changed in
the heirachy of the site (which will use URL rewriting). Is the Hash Code
based on this URL, or on some unchanging properties (like the filename and
path from root, for example)?

If its based on the re-written url, then this will change and so, again the
connection between the unique identifier and the database record will be
broken...

Thanks,
JJ


"Steven Cheng[MSFT]" <stcheng@online.microsoft.com> wrote in message
news:RBn78BjBIHA.5204@TK2MSFTNGHUB02.phx.gbl...
> Hi JJ,
>
> To answer your question first, Yes, UniqueID is a unique identifer for a
> given control, but this is only guaranteed at page level(for this web form
> page), it help make sure that on the client-side rendered html form, every
> control won't have duplicated client identifiers.
>
> for your scenario, you just need to make sure each webpart control(of your
> custom one) instance has its own unique value and this value need to be
> automatically generated, correct? If so,I think you can consider the
> following approaches:
>
> 1) Use the Page's "GetHashCode" to get its instance identifier and then
> combine it with your control's uniqueID(or also HashCode value) to
> generate
> an new identifer.
>
> 2) You can use the current timestamp and combine your control's ID to
> generate an identifer
>
> How do you think?
>
> If there is anything I misunderstood, please feel free to post here.
>
> Sincerely,
>
> Steven Cheng
>
> Microsoft MSDN Online Support Lead
>
>
>
> ==================================================
>
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
> ications.
>
>
>
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 1 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions or complex
> project analysis and dump analysis issues. Issues of this nature are best
> handled working with a dedicated Microsoft Support Engineer by contacting
> Microsoft Customer Support Services (CSS) at
> http://msdn.microsoft.com/subscriptions/support/default.aspx.
>
> ==================================================
>
>
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
> --------------------
>>From: "JJ" <abc@xyz.com>
>>References: <O9U2W9dBIHA.4880@TK2MSFTNGP03.phx.gbl>
>>Subject: Re: Web Parts Instances
>>Date: Wed, 3 Oct 2007 18:44:03 +0100
>>Ok I think, or rather hope, I've gone some way to answering my own
> question.
>>
>>I've used the controls UniqueID property to establish a connection between
>>the instance an a unique record in the database. From my very limited
> tests,
>>this UniqueID property doesn't seem to change if you change the position
> of
>>the web part on the page, or if you add others around it, or change the
>>order.
>>
>>My next quesiton is, is this uniqueID unique throughout the entire site,
> or
>>do I need to add some other unique information to it (like the path to the
>>current page, for instance)? I suspect I do, but would appreciate some
>>advice here...
>>
>>JJ
>>
>>
>>"JJ" <abc@xyz.com> wrote in message
>>news:O9U2W9dBIHA.4880@TK2MSFTNGP03.phx.gbl...
>>> I'm newish to web parts:
>>>
>>> Say for example I create a web part from a control that displays some
> text
>>> on a web page. The control would allow some text, which is stored in an
>>> sql database, to be edited. The user could in theory add several
> instances
>>> of this web part to a page, and each instance needs to display its
> unique
>>> text as stored in the corresponding record in the database.
>>>
>>> In order to achieve this I would imagine I need to tie a web part
> instance
>>> to some sort of unique identifier. How would I do this? In other words,
>>> how is it possible for different instances of the same web part to refer
>>> to unique records?
>>>
>>> Please tell me if I'm not making myself clear.
>>> JJ
>>>
>>
>>
>>
>


JJ
Posted: Thursday, October 04, 2007 3:14:56 PM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 04/10/2007 15:14:56
Date: Thu, 4 Oct 2007 14:14:56 +0100

I'm really stuck here if anyone can help.

I'm basically trying to create a html editor web part (not using
Sharepoint). In order to do this I need to somehow hard wire the web part
instance (remembering that there may be more than one instance of this web
part on any page, and that the pages url may change also due to the cms/url
rewriting) to a database record that stores the actual html.

My problem seems to come down to:
1) how you would pick a unique identifier that could be used as a key to the
database record,
2) how you would keep this constant whenever the web part was moved, page
url changed (via url re-writing) etc,
3) how the unique identifier would persist (if it was not somehow calculated
each time the web part loads) indefinately

??

Web parts seem to me to be an obvious approach to building a 'simple' cms,
in that an 'editor' can add/remove parts via the shared scope. What I am
trying to do here is create a part that also allows them to edit what text
is within one of the parts.

Judging by the lack of info around on this issue, I am either doing
something that will never work, or I am missing something obvious....

Please help if you can,
JJ



"JJ" <abc@xyz.com> wrote in message
news:OEVTdemBIHA.3916@TK2MSFTNGP02.phx.gbl...
> Another thougth about the GetHashCode + Unique ID method:
> In this scenario I am building a limited CMS system. It is possible
> therefore that the URL of the page may change if its location in changed
> in the heirachy of the site (which will use URL rewriting). Is the Hash
> Code based on this URL, or on some unchanging properties (like the
> filename and path from root, for example)?
>
> If its based on the re-written url, then this will change and so, again
> the connection between the unique identifier and the database record will
> be broken...
>
> Thanks,
> JJ
>
>
> "Steven Cheng[MSFT]" <stcheng@online.microsoft.com> wrote in message
> news:RBn78BjBIHA.5204@TK2MSFTNGHUB02.phx.gbl...
>> Hi JJ,
>>
>> To answer your question first, Yes, UniqueID is a unique identifer for a
>> given control, but this is only guaranteed at page level(for this web
>> form
>> page), it help make sure that on the client-side rendered html form,
>> every
>> control won't have duplicated client identifiers.
>>
>> for your scenario, you just need to make sure each webpart control(of
>> your
>> custom one) instance has its own unique value and this value need to be
>> automatically generated, correct? If so,I think you can consider the
>> following approaches:
>>
>> 1) Use the Page's "GetHashCode" to get its instance identifier and then
>> combine it with your control's uniqueID(or also HashCode value) to
>> generate
>> an new identifer.
>>
>> 2) You can use the current timestamp and combine your control's ID to
>> generate an identifer
>>
>> How do you think?
>>
>> If there is anything I misunderstood, please feel free to post here.
>>
>> Sincerely,
>>
>> Steven Cheng
>>
>> Microsoft MSDN Online Support Lead
>>
>>
>>
>> ==================================================
>>
>> Get notification to my posts through email? Please refer to
>> http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
>> ications.
>>
>>
>>
>> Note: The MSDN Managed Newsgroup support offering is for non-urgent
>> issues
>> where an initial response from the community or a Microsoft Support
>> Engineer within 1 business day is acceptable. Please note that each
>> follow
>> up response may take approximately 2 business days as the support
>> professional working with you may need further investigation to reach the
>> most efficient resolution. The offering is not appropriate for situations
>> that require urgent, real-time or phone-based interactions or complex
>> project analysis and dump analysis issues. Issues of this nature are best
>> handled working with a dedicated Microsoft Support Engineer by contacting
>> Microsoft Customer Support Services (CSS) at
>> http://msdn.microsoft.com/subscriptions/support/default.aspx.
>>
>> ==================================================
>>
>>
>> This posting is provided "AS IS" with no warranties, and confers no
>> rights.
>>
>> --------------------
>>>From: "JJ" <abc@xyz.com>
>>>References: <O9U2W9dBIHA.4880@TK2MSFTNGP03.phx.gbl>
>>>Subject: Re: Web Parts Instances
>>>Date: Wed, 3 Oct 2007 18:44:03 +0100
>>>Ok I think, or rather hope, I've gone some way to answering my own
>> question.
>>>
>>>I've used the controls UniqueID property to establish a connection
>>>between
>>>the instance an a unique record in the database. From my very limited
>> tests,
>>>this UniqueID property doesn't seem to change if you change the position
>> of
>>>the web part on the page, or if you add others around it, or change the
>>>order.
>>>
>>>My next quesiton is, is this uniqueID unique throughout the entire site,
>> or
>>>do I need to add some other unique information to it (like the path to
>>>the
>>>current page, for instance)? I suspect I do, but would appreciate some
>>>advice here...
>>>
>>>JJ
>>>
>>>
>>>"JJ" <abc@xyz.com> wrote in message
>>>news:O9U2W9dBIHA.4880@TK2MSFTNGP03.phx.gbl...
>>>> I'm newish to web parts:
>>>>
>>>> Say for example I create a web part from a control that displays some
>> text
>>>> on a web page. The control would allow some text, which is stored in an
>>>> sql database, to be edited. The user could in theory add several
>> instances
>>>> of this web part to a page, and each instance needs to display its
>> unique
>>>> text as stored in the corresponding record in the database.
>>>>
>>>> In order to achieve this I would imagine I need to tie a web part
>> instance
>>>> to some sort of unique identifier. How would I do this? In other words,
>>>> how is it possible for different instances of the same web part to
>>>> refer
>>>> to unique records?
>>>>
>>>> Please tell me if I'm not making myself clear.
>>>> JJ
>>>>
>>>
>>>
>>>
>>
>
>


Steven Cheng[MSFT]
Posted: Friday, October 05, 2007 3:57:45 AM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 05/10/2007 03:57:45
Date: Fri, 05 Oct 2007 03:57:45 GMT

Thanks for your followup JJ,

To answer the question in former messages:

*Yes, GetHasCode implementation may vary between different framework
version, it has opacity.

*Sure, timestamp approach can only make sure you assign a new created
instance a unique ID, it should be our own code logic to always associcate
a given ID with a certain objecct instance(for your case, the object is
Editor web part).

In original messages, I haven't realized that you need to associate your
editor webpart with database record. Would you provide some more business
code logic info on this? Now, what I understand is that you may have
multiple editor webpart instances on a page and each of them should map to
a unique record in database. And next time user open page and open new
editor webparts, you need to associate them to database records
again,correct?

If this is the case, I'm afraid it is quite hard to archive. Because
generally, the mapping sequence should be as below:

** you retrieve records from database

** you create editor webparts based on those records in databases

It's quite hard to create webparts and then associate them with database
records. Because you haven't any identifer for those new created webparts,
right? Mostly, in web application, you may consider using current user's
identifer(if there is user authentication in your application) to uniquely
identify an object. Do you think it is possible to do this in your
application?

Anyway, please feel free to let me know if there is still anything I missed
here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.




>Subject: Re: Web Parts Instances
>Date: Thu, 4 Oct 2007 14:14:56 +0100

>
>I'm really stuck here if anyone can help.
>
>I'm basically trying to create a html editor web part (not using
>Sharepoint). In order to do this I need to somehow hard wire the web part
>instance (remembering that there may be more than one instance of this web
>part on any page, and that the pages url may change also due to the
cms/url
>rewriting) to a database record that stores the actual html.
>
>My problem seems to come down to:
>1) how you would pick a unique identifier that could be used as a key to
the
>database record,
>2) how you would keep this constant whenever the web part was moved, page
>url changed (via url re-writing) etc,
>3) how the unique identifier would persist (if it was not somehow
calculated
>each time the web part loads) indefinately
>
>??
>
>Web parts seem to me to be an obvious approach to building a 'simple' cms,
>in that an 'editor' can add/remove parts via the shared scope. What I am
>trying to do here is create a part that also allows them to edit what text
>is within one of the parts.
>
>Judging by the lack of info around on this issue, I am either doing
>something that will never work, or I am missing something obvious....
>
>Please help if you can,
>JJ
>
>
>
>"JJ" <abc@xyz.com> wrote in message
>news:OEVTdemBIHA.3916@TK2MSFTNGP02.phx.gbl...
>> Another thougth about the GetHashCode + Unique ID method:
>> In this scenario I am building a limited CMS system. It is possible
>> therefore that the URL of the page may change if its location in changed
>> in the heirachy of the site (which will use URL rewriting). Is the Hash
>> Code based on this URL, or on some unchanging properties (like the
>> filename and path from root, for example)?
>>
>> If its based on the re-written url, then this will change and so, again
>> the connection between the unique identifier and the database record
will
>> be broken...
>>
>> Thanks,
>> JJ
>>
>>
>> "Steven Cheng[MSFT]" <stcheng@online.microsoft.com> wrote in message
>> news:RBn78BjBIHA.5204@TK2MSFTNGHUB02.phx.gbl...
>>> Hi JJ,
>>>
>>> To answer your question first, Yes, UniqueID is a unique identifer for a
>>> given control, but this is only guaranteed at page level(for this web
>>> form
>>> page), it help make sure that on the client-side rendered html form,
>>> every
>>> control won't have duplicated client identifiers.
>>>
>>> for your scenario, you just need to make sure each webpart control(of
>>> your
>>> custom one) instance has its own unique value and this value need to be
>>> automatically generated, correct? If so,I think you can consider the
>>> following approaches:
>>>
>>> 1) Use the Page's "GetHashCode" to get its instance identifier and then
>>> combine it with your control's uniqueID(or also HashCode value) to
>>> generate
>>> an new identifer.
>>>
>>> 2) You can use the current timestamp and combine your control's ID to
>>> generate an identifer
>>>
>>> How do you think?
>>>
>>> If there is anything I misunderstood, please feel free to post here.
>>>
>>> Sincerely,
>>>
>>> Steven Cheng
>>>
>>> Microsoft MSDN Online Support Lead
>>>
>>>
>>>
>>> ==================================================
>>>
>>> Get notification to my posts through email? Please refer to
>>>
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
>>> ications.
>>>
>>>
>>>
>>> Note: The MSDN Managed Newsgroup support offering is for non-urgent
>>> issues
>>> where an initial response from the community or a Microsoft Support
>>> Engineer within 1 business day is acceptable. Please note that each
>>> follow
>>> up response may take approximately 2 business days as the support
>>> professional working with you may need further investigation to reach
the
>>> most efficient resolution. The offering is not appropriate for
situations
>>> that require urgent, real-time or phone-based interactions or complex
>>> project analysis and dump analysis issues. Issues of this nature are
best
>>> handled working with a dedicated Microsoft Support Engineer by
contacting
>>> Microsoft Customer Support Services (CSS) at
>>> http://msdn.microsoft.com/subscriptions/support/default.aspx.
>>>
>>> ==================================================
>>>
>>>
>>> This posting is provided "AS IS" with no warranties, and confers no
>>> rights.
>>>
>>> --------------------
>>>>From: "JJ" <abc@xyz.com>
>>>>References: <O9U2W9dBIHA.4880@TK2MSFTNGP03.phx.gbl>
>>>>Subject: Re: Web Parts Instances
>>>>Date: Wed, 3 Oct 2007 18:44:03 +0100
>>>>Ok I think, or rather hope, I've gone some way to answering my own
>>> question.
>>>>
>>>>I've used the controls UniqueID property to establish a connection
>>>>between
>>>>the instance an a unique record in the database. From my very limited
>>> tests,
>>>>this UniqueID property doesn't seem to change if you change the position
>>> of
>>>>the web part on the page, or if you add others around it, or change the
>>>>order.
>>>>
>>>>My next quesiton is, is this uniqueID unique throughout the entire site,
>>> or
>>>>do I need to add some other unique information to it (like the path to
>>>>the
>>>>current page, for instance)? I suspect I do, but would appreciate some
>>>>advice here...
>>>>
>>>>JJ
>>>>
>>>>
>>>>"JJ" <abc@xyz.com> wrote in message
>>>>news:O9U2W9dBIHA.4880@TK2MSFTNGP03.phx.gbl...
>>>>> I'm newish to web parts:
>>>>>
>>>>> Say for example I create a web part from a control that displays some
>>> text
>>>>> on a web page. The control would allow some text, which is stored in
an
>>>>> sql database, to be edited. The user could in theory add several
>>> instances
>>>>> of this web part to a page, and each instance needs to display its
>>> unique
>>>>> text as stored in the corresponding record in the database.
>>>>>
>>>>> In order to achieve this I would imagine I need to tie a web part
>>> instance
>>>>> to some sort of unique identifier. How would I do this? In other
words,
>>>>> how is it possible for different instances of the same web part to
>>>>> refer
>>>>> to unique records?
>>>>>
>>>>> Please tell me if I'm not making myself clear.
>>>>> JJ
>>>>>
>>>>
>>>>
>>>>
>>>
>>
>>
>
>
>

JJ
Posted: Friday, October 05, 2007 11:44:35 AM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 05/10/2007 11:44:35
Date: Fri, 5 Oct 2007 10:44:35 +0100

Dear Steven,

Thanks for you response. In reply:

Yes I do need to associate a web part instance with a specific database
record. I find it hard to beleive this is not possible - how does
personalisation know which web part is which when applying personalisation
(shared scope) information held in database records?

I have no code as yet as I have been trying to overcome this particular
issue before continuing. The requirement is quite simple and I am sure
others must have done this: I simply want a html editor web part that I can
place (in shared scope) on a page, as many times as I wish. You can see how
this would be a building block for a content management system.

Currently, I use a html editor control (not using web parts), which uses a
querystring parameter to identify the database record which holds the html.
Clearly this is not the solution that should be applied with multiple
instances of the same control/webpart.

It would not be possible to use the current username as an identifier
because:
(1) we're talking about adding/moving/removing web parts for all users
(shared scope);
(2) I can't see how that would help in associating a particular web part
instance with a particular database record.

I could see how your suggestion with using the GetHashCode(page) +
UniqueID(control) could be calculated consistently each time the web part
loaded - i.e. use that as a key in the database record - however, when I
upgrade framework I would probably lose all ties between the web part and
the database record. That would be a real problem.

Surely this can be done??
JJ

"Steven Cheng[MSFT]" <stcheng@online.microsoft.com> wrote in message
news:se9erPwBIHA.5204@TK2MSFTNGHUB02.phx.gbl...
> Thanks for your followup JJ,
>
> To answer the question in former messages:
>
> *Yes, GetHasCode implementation may vary between different framework
> version, it has opacity.
>
> *Sure, timestamp approach can only make sure you assign a new created
> instance a unique ID, it should be our own code logic to always associcate
> a given ID with a certain objecct instance(for your case, the object is
> Editor web part).
>
> In original messages, I haven't realized that you need to associate your
> editor webpart with database record. Would you provide some more business
> code logic info on this? Now, what I understand is that you may have
> multiple editor webpart instances on a page and each of them should map to
> a unique record in database. And next time user open page and open new
> editor webparts, you need to associate them to database records
> again,correct?
>
> If this is the case, I'm afraid it is quite hard to archive. Because
> generally, the mapping sequence should be as below:
>
> ** you retrieve records from database
>
> ** you create editor webparts based on those records in databases
>
> It's quite hard to create webparts and then associate them with database
> records. Because you haven't any identifer for those new created webparts,
> right? Mostly, in web application, you may consider using current user's
> identifer(if there is user authentication in your application) to uniquely
> identify an object. Do you think it is possible to do this in your
> application?
>
> Anyway, please feel free to let me know if there is still anything I
> missed
> here.
>
> Sincerely,
>
> Steven Cheng
>
> Microsoft MSDN Online Support Lead
>
>
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
>
> --------------------
>
>>Subject: Re: Web Parts Instances
>>Date: Thu, 4 Oct 2007 14:14:56 +0100
>
>>
>>I'm really stuck here if anyone can help.
>>
>>I'm basically trying to create a html editor web part (not using
>>Sharepoint). In order to do this I need to somehow hard wire the web part
>>instance (remembering that there may be more than one instance of this web
>>part on any page, and that the pages url may change also due to the
> cms/url
>>rewriting) to a database record that stores the actual html.
>>
>>My problem seems to come down to:
>>1) how you would pick a unique identifier that could be used as a key to
> the
>>database record,
>>2) how you would keep this constant whenever the web part was moved, page
>>url changed (via url re-writing) etc,
>>3) how the unique identifier would persist (if it was not somehow
> calculated
>>each time the web part loads) indefinately
>>
>>??
>>
>>Web parts seem to me to be an obvious approach to building a 'simple' cms,
>>in that an 'editor' can add/remove parts via the shared scope. What I am
>>trying to do here is create a part that also allows them to edit what text
>>is within one of the parts.
>>
>>Judging by the lack of info around on this issue, I am either doing
>>something that will never work, or I am missing something obvious....
>>
>>Please help if you can,
>>JJ
>>
>>
>>
>>"JJ" <abc@xyz.com> wrote in message
>>news:OEVTdemBIHA.3916@TK2MSFTNGP02.phx.gbl...
>>> Another thougth about the GetHashCode + Unique ID method:
>>> In this scenario I am building a limited CMS system. It is possible
>>> therefore that the URL of the page may change if its location in changed
>>> in the heirachy of the site (which will use URL rewriting). Is the Hash
>>> Code based on this URL, or on some unchanging properties (like the
>>> filename and path from root, for example)?
>>>
>>> If its based on the re-written url, then this will change and so, again
>>> the connection between the unique identifier and the database record
> will
>>> be broken...
>>>
>>> Thanks,
>>> JJ
>>>
>>>
>>> "Steven Cheng[MSFT]" <stcheng@online.microsoft.com> wrote in message
>>> news:RBn78BjBIHA.5204@TK2MSFTNGHUB02.phx.gbl...
>>>> Hi JJ,
>>>>
>>>> To answer your question first, Yes, UniqueID is a unique identifer for
>>>> a
>>>> given control, but this is only guaranteed at page level(for this web
>>>> form
>>>> page), it help make sure that on the client-side rendered html form,
>>>> every
>>>> control won't have duplicated client identifiers.
>>>>
>>>> for your scenario, you just need to make sure each webpart control(of
>>>> your
>>>> custom one) instance has its own unique value and this value need to be
>>>> automatically generated, correct? If so,I think you can consider the
>>>> following approaches:
>>>>
>>>> 1) Use the Page's "GetHashCode" to get its instance identifier and then
>>>> combine it with your control's uniqueID(or also HashCode value) to
>>>> generate
>>>> an new identifer.
>>>>
>>>> 2) You can use the current timestamp and combine your control's ID to
>>>> generate an identifer
>>>>
>>>> How do you think?
>>>>
>>>> If there is anything I misunderstood, please feel free to post here.
>>>>
>>>> Sincerely,
>>>>
>>>> Steven Cheng
>>>>
>>>> Microsoft MSDN Online Support Lead
>>>>
>>>>
>>>>
>>>> ==================================================
>>>>
>>>> Get notification to my posts through email? Please refer to
>>>>
> http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
>>>> ications.
>>>>
>>>>
>>>>
>>>> Note: The MSDN Managed Newsgroup support offering is for non-urgent
>>>> issues
>>>> where an initial response from the community or a Microsoft Support
>>>> Engineer within 1 business day is acceptable. Please note that each
>>>> follow
>>>> up response may take approximately 2 business days as the support
>>>> professional working with you may need further investigation to reach
> the
>>>> most efficient resolution. The offering is not appropriate for
> situations
>>>> that require urgent, real-time or phone-based interactions or complex
>>>> project analysis and dump analysis issues. Issues of this nature are
> best
>>>> handled working with a dedicated Microsoft Support Engineer by
> contacting
>>>> Microsoft Customer Support Services (CSS) at
>>>> http://msdn.microsoft.com/subscriptions/support/default.aspx.
>>>>
>>>> ==================================================
>>>>
>>>>
>>>> This posting is provided "AS IS" with no warranties, and confers no
>>>> rights.
>>>>
>>>> --------------------
>>>>>From: "JJ" <abc@xyz.com>
>>>>>References: <O9U2W9dBIHA.4880@TK2MSFTNGP03.phx.gbl>
>>>>>Subject: Re: Web Parts Instances
>>>>>Date: Wed, 3 Oct 2007 18:44:03 +0100
>>>>>Ok I think, or rather hope, I've gone some way to answering my own
>>>> question.
>>>>>
>>>>>I've used the controls UniqueID property to establish a connection
>>>>>between
>>>>>the instance an a unique record in the database. From my very limited
>>>> tests,
>>>>>this UniqueID property doesn't seem to change if you change the
>>>>>position
>>>> of
>>>>>the web part on the page, or if you add others around it, or change the
>>>>>order.
>>>>>
>>>>>My next quesiton is, is this uniqueID unique throughout the entire
>>>>>site,
>>>> or
>>>>>do I need to add some other unique information to it (like the path to
>>>>>the
>>>>>current page, for instance)? I suspect I do, but would appreciate some
>>>>>advice here...
>>>>>
>>>>>JJ
>>>>>
>>>>>
>>>>>"JJ" <abc@xyz.com> wrote in message
>>>>>news:O9U2W9dBIHA.4880@TK2MSFTNGP03.phx.gbl...
>>>>>> I'm newish to web parts:
>>>>>>
>>>>>> Say for example I create a web part from a control that displays some
>>>> text
>>>>>> on a web page. The control would allow some text, which is stored in
> an
>>>>>> sql database, to be edited. The user could in theory add several
>>>> instances
>>>>>> of this web part to a page, and each instance needs to display its
>>>> unique
>>>>>> text as stored in the corresponding record in the database.
>>>>>>
>>>>>> In order to achieve this I would imagine I need to tie a web part
>>>> instance
>>>>>> to some sort of unique identifier. How would I do this? In other
> words,
>>>>>> how is it possible for different instances of the same web part to
>>>>>> refer
>>>>>> to unique records?
>>>>>>
>>>>>> Please tell me if I'm not making myself clear.
>>>>>> JJ
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>
>>>
>>
>>
>>
>


JJ
Posted: Friday, October 05, 2007 11:59:45 AM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 05/10/2007 11:59:45
Date: Fri, 5 Oct 2007 10:59:45 +0100

Here's a small example of what I am trying to do. This site is based on web
parts. You can add multiple instances of the same web part on a page and
each web part accessed different database records. Go to this site:
http://www.pageflakes.com/

And choose to Personalize your page. Now choose to add the 'Sticky Note' web
part, then add another one. You can see that you can type different text in
each web part and move the web parts around. Each web part is associated
with a different record stored in the database.

This is a simplified version of what I need. This surely proves that there
is a way to do this. Yes, the page information is based on a per user basis,
but you still have the problem of associating a particular web part with a
particular database record for each user (i.e. using the username as a key
to finding the record is not enough).

??

"Steven Cheng[MSFT]" <stcheng@online.microsoft.com> wrote in message
news:se9erPwBIHA.5204@TK2MSFTNGHUB02.phx.gbl...
> Thanks for your followup JJ,
>
> To answer the question in former messages:
>
> *Yes, GetHasCode implementation may vary between different framework
> version, it has opacity.
>
> *Sure, timestamp approach can only make sure you assign a new created
> instance a unique ID, it should be our own code logic to always associcate
> a given ID with a certain objecct instance(for your case, the object is
> Editor web part).
>
> In original messages, I haven't realized that you need to associate your
> editor webpart with database record. Would you provide some more business
> code logic info on this? Now, what I understand is that you may have
> multiple editor webpart instances on a page and each of them should map to
> a unique record in database. And next time user open page and open new
> editor webparts, you need to associate them to database records
> again,correct?
>
> If this is the case, I'm afraid it is quite hard to archive. Because
> generally, the mapping sequence should be as below:
>
> ** you retrieve records from database
>
> ** you create editor webparts based on those records in databases
>
> It's quite hard to create webparts and then associate them with database
> records. Because you haven't any identifer for those new created webparts,
> right? Mostly, in web application, you may consider using current user's
> identifer(if there is user authentication in your application) to uniquely
> identify an object. Do you think it is possible to do this in your
> application?
>
> Anyway, please feel free to let me know if there is still anything I
> missed
> here.
>
> Sincerely,
>
> Steven Cheng
>
> Microsoft MSDN Online Support Lead
>
>
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
>
> --------------------
>
>>Subject: Re: Web Parts Instances
>>Date: Thu, 4 Oct 2007 14:14:56 +0100
>
>>
>>I'm really stuck here if anyone can help.
>>
>>I'm basically trying to create a html editor web part (not using
>>Sharepoint). In order to do this I need to somehow hard wire the web part
>>instance (remembering that there may be more than one instance of this web
>>part on any page, and that the pages url may change also due to the
> cms/url
>>rewriting) to a database record that stores the actual html.
>>
>>My problem seems to come down to:
>>1) how you would pick a unique identifier that could be used as a key to
> the
>>database record,
>>2) how you would keep this constant whenever the web part was moved, page
>>url changed (via url re-writing) etc,
>>3) how the unique identifier would persist (if it was not somehow
> calculated
>>each time the web part loads) indefinately
>>
>>??
>>
>>Web parts seem to me to be an obvious approach to building a 'simple' cms,
>>in that an 'editor' can add/remove parts via the shared scope. What I am
>>trying to do here is create a part that also allows them to edit what text
>>is within one of the parts.
>>
>>Judging by the lack of info around on this issue, I am either doing
>>something that will never work, or I am missing something obvious....
>>
>>Please help if you can,
>>JJ
>>
>>
>>
>>"JJ" <abc@xyz.com> wrote in message
>>news:OEVTdemBIHA.3916@TK2MSFTNGP02.phx.gbl...
>>> Another thougth about the GetHashCode + Unique ID method:
>>> In this scenario I am building a limited CMS system. It is possible
>>> therefore that the URL of the page may change if its location in changed
>>> in the heirachy of the site (which will use URL rewriting). Is the Hash
>>> Code based on this URL, or on some unchanging properties (like the
>>> filename and path from root, for example)?
>>>
>>> If its based on the re-written url, then this will change and so, again
>>> the connection between the unique identifier and the database record
> will
>>> be broken...
>>>
>>> Thanks,
>>> JJ
>>>
>>>
>>> "Steven Cheng[MSFT]" <stcheng@online.microsoft.com> wrote in message
>>> news:RBn78BjBIHA.5204@TK2MSFTNGHUB02.phx.gbl...
>>>> Hi JJ,
>>>>
>>>> To answer your question first, Yes, UniqueID is a unique identifer for
>>>> a
>>>> given control, but this is only guaranteed at page level(for this web
>>>> form
>>>> page), it help make sure that on the client-side rendered html form,
>>>> every
>>>> control won't have duplicated client identifiers.
>>>>
>>>> for your scenario, you just need to make sure each webpart control(of
>>>> your
>>>> custom one) instance has its own unique value and this value need to be
>>>> automatically generated, correct? If so,I think you can consider the
>>>> following approaches:
>>>>
>>>> 1) Use the Page's "GetHashCode" to get its instance identifier and then
>>>> combine it with your control's uniqueID(or also HashCode value) to
>>>> generate
>>>> an new identifer.
>>>>
>>>> 2) You can use the current timestamp and combine your control's ID to
>>>> generate an identifer
>>>>
>>>> How do you think?
>>>>
>>>> If there is anything I misunderstood, please feel free to post here.
>>>>
>>>> Sincerely,
>>>>
>>>> Steven Cheng
>>>>
>>>> Microsoft MSDN Online Support Lead
>>>>
>>>>
>>>>
>>>> ==================================================
>>>>
>>>> Get notification to my posts through email? Please refer to
>>>>
> http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
>>>> ications.
>>>>
>>>>
>>>>
>>>> Note: The MSDN Managed Newsgroup support offering is for non-urgent
>>>> issues
>>>> where an initial response from the community or a Microsoft Support
>>>> Engineer within 1 business day is acceptable. Please note that each
>>>> follow
>>>> up response may take approximately 2 business days as the support
>>>> professional working with you may need further investigation to reach
> the
>>>> most efficient resolution. The offering is not appropriate for
> situations
>>>> that require urgent, real-time or phone-based interactions or complex
>>>> project analysis and dump analysis issues. Issues of this nature are
> best
>>>> handled working with a dedicated Microsoft Support Engineer by
> contacting
>>>> Microsoft Customer Support Services (CSS) at
>>>> http://msdn.microsoft.com/subscriptions/support/default.aspx.
>>>>
>>>> ==================================================
>>>>
>>>>
>>>> This posting is provided "AS IS" with no warranties, and confers no
>>>> rights.
>>>>
>>>> --------------------
>>>>>From: "JJ" <abc@xyz.com>
>>>>>References: <O9U2W9dBIHA.4880@TK2MSFTNGP03.phx.gbl>
>>>>>Subject: Re: Web Parts Instances
>>>>>Date: Wed, 3 Oct 2007 18:44:03 +0100
>>>>>Ok I think, or rather hope, I've gone some way to answering my own
>>>> question.
>>>>>
>>>>>I've used the controls UniqueID property to establish a connection
>>>>>between
>>>>>the instance an a unique record in the database. From my very limited
>>>> tests,
>>>>>this UniqueID property doesn't seem to change if you change the
>>>>>position
>>>> of
>>>>>the web part on the page, or if you add others around it, or change the
>>>>>order.
>>>>>
>>>>>My next quesiton is, is this uniqueID unique throughout the entire
>>>>>site,
>>>> or
>>>>>do I need to add some other unique information to it (like the path to
>>>>>the
>>>>>current page, for instance)? I suspect I do, but would appreciate some
>>>>>advice here...
>>>>>
>>>>>JJ
>>>>>
>>>>>
>>>>>"JJ" <abc@xyz.com> wrote in message
>>>>>news:O9U2W9dBIHA.4880@TK2MSFTNGP03.phx.gbl...
>>>>>> I'm newish to web parts:
>>>>>>
>>>>>> Say for example I create a web part from a control that displays some
>>>> text
>>>>>> on a web page. The control would allow some text, which is stored in
> an
>>>>>> sql database, to be edited. The user could in theory add several
>>>> instances
>>>>>> of this web part to a page, and each instance needs to display its
>>>> unique
>>>>>> text as stored in the corresponding record in the database.
>>>>>>
>>>>>> In order to achieve this I would imagine I need to tie a web part
>>>> instance
>>>>>> to some sort of unique identifier. How would I do this? In other
> words,
>>>>>> how is it possible for different instances of the same web part to
>>>>>> refer
>>>>>> to unique records?
>>>>>>
>>>>>> Please tell me if I'm not making myself clear.
>>>>>> JJ
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>
>>>
>>
>>
>>
>


JJ
Posted: Friday, October 05, 2007 2:57:23 PM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 05/10/2007 14:57:23
Date: Fri, 5 Oct 2007 13:57:23 +0100

Better still they have a notepad 'pageflake' there (you need to 'Browse all
flakes' when personalizing your page), and that is exactly what I am trying
to create.



"JJ" <abc@xyz.com> wrote in message
news:%23jo9gZzBIHA.5752@TK2MSFTNGP02.phx.gbl...
> Here's a small example of what I am trying to do. This site is based on
> web parts. You can add multiple instances of the same web part on a page
> and each web part accessed different database records. Go to this site:
> http://www.pageflakes.com/
>
> And choose to Personalize your page. Now choose to add the 'Sticky Note'
> web part, then add another one. You can see that you can type different
> text in each web part and move the web parts around. Each web part is
> associated with a different record stored in the database.
>
> This is a simplified version of what I need. This surely proves that there
> is a way to do this. Yes, the page information is based on a per user
> basis, but you still have the problem of associating a particular web part
> with a particular database record for each user (i.e. using the username
> as a key to finding the record is not enough).
>
> ??
>
> "Steven Cheng[MSFT]" <stcheng@online.microsoft.com> wrote in message
> news:se9erPwBIHA.5204@TK2MSFTNGHUB02.phx.gbl...
>> Thanks for your followup JJ,
>>
>> To answer the question in former messages:
>>
>> *Yes, GetHasCode implementation may vary between different framework
>> version, it has opacity.
>>
>> *Sure, timestamp approach can only make sure you assign a new created
>> instance a unique ID, it should be our own code logic to always
>> associcate
>> a given ID with a certain objecct instance(for your case, the object is
>> Editor web part).
>>
>> In original messages, I haven't realized that you need to associate your
>> editor webpart with database record. Would you provide some more business
>> code logic info on this? Now, what I understand is that you may have
>> multiple editor webpart instances on a page and each of them should map
>> to
>> a unique record in database. And next time user open page and open new
>> editor webparts, you need to associate them to database records
>> again,correct?
>>
>> If this is the case, I'm afraid it is quite hard to archive. Because
>> generally, the mapping sequence should be as below:
>>
>> ** you retrieve records from database
>>
>> ** you create editor webparts based on those records in databases
>>
>> It's quite hard to create webparts and then associate them with database
>> records. Because you haven't any identifer for those new created
>> webparts,
>> right? Mostly, in web application, you may consider using current user's
>> identifer(if there is user authentication in your application) to
>> uniquely
>> identify an object. Do you think it is possible to do this in your
>> application?
>>
>> Anyway, please feel free to let me know if there is still anything I
>> missed
>> here.
>>
>> Sincerely,
>>
>> Steven Cheng
>>
>> Microsoft MSDN Online Support Lead
>>
>>
>> This posting is provided "AS IS" with no warranties, and confers no
>> rights.
>>
>>
>> --------------------
>>
>>>Subject: Re: Web Parts Instances
>>>Date: Thu, 4 Oct 2007 14:14:56 +0100
>>
>>>
>>>I'm really stuck here if anyone can help.
>>>
>>>I'm basically trying to create a html editor web part (not using
>>>Sharepoint). In order to do this I need to somehow hard wire the web part
>>>instance (remembering that there may be more than one instance of this
>>>web
>>>part on any page, and that the pages url may change also due to the
>> cms/url
>>>rewriting) to a database record that stores the actual html.
>>>
>>>My problem seems to come down to:
>>>1) how you would pick a unique identifier that could be used as a key to
>> the
>>>database record,
>>>2) how you would keep this constant whenever the web part was moved, page
>>>url changed (via url re-writing) etc,
>>>3) how the unique identifier would persist (if it was not somehow
>> calculated
>>>each time the web part loads) indefinately
>>>
>>>??
>>>
>>>Web parts seem to me to be an obvious approach to building a 'simple'
>>>cms,
>>>in that an 'editor' can add/remove parts via the shared scope. What I am
>>>trying to do here is create a part that also allows them to edit what
>>>text
>>>is within one of the parts.
>>>
>>>Judging by the lack of info around on this issue, I am either doing
>>>something that will never work, or I am missing something obvious....
>>>
>>>Please help if you can,
>>>JJ
>>>
>>>
>>>
>>>"JJ" <abc@xyz.com> wrote in message
>>>news:OEVTdemBIHA.3916@TK2MSFTNGP02.phx.gbl...
>>>> Another thougth about the GetHashCode + Unique ID method:
>>>> In this scenario I am building a limited CMS system. It is possible
>>>> therefore that the URL of the page may change if its location in
>>>> changed
>>>> in the heirachy of the site (which will use URL rewriting). Is the Hash
>>>> Code based on this URL, or on some unchanging properties (like the
>>>> filename and path from root, for example)?
>>>>
>>>> If its based on the re-written url, then this will change and so, again
>>>> the connection between the unique identifier and the database record
>> will
>>>> be broken...
>>>>
>>>> Thanks,
>>>> JJ
>>>>
>>>>
>>>> "Steven Cheng[MSFT]" <stcheng@online.microsoft.com> wrote in message
>>>> news:RBn78BjBIHA.5204@TK2MSFTNGHUB02.phx.gbl...
>>>>> Hi JJ,
>>>>>
>>>>> To answer your question first, Yes, UniqueID is a unique identifer for
>>>>> a
>>>>> given control, but this is only guaranteed at page level(for this web
>>>>> form
>>>>> page), it help make sure that on the client-side rendered html form,
>>>>> every
>>>>> control won't have duplicated client identifiers.
>>>>>
>>>>> for your scenario, you just need to make sure each webpart control(of
>>>>> your
>>>>> custom one) instance has its own unique value and this value need to
>>>>> be
>>>>> automatically generated, correct? If so,I think you can consider the
>>>>> following approaches:
>>>>>
>>>>> 1) Use the Page's "GetHashCode" to get its instance identifier and
>>>>> then
>>>>> combine it with your control's uniqueID(or also HashCode value) to
>>>>> generate
>>>>> an new identifer.
>>>>>
>>>>> 2) You can use the current timestamp and combine your control's ID to
>>>>> generate an identifer
>>>>>
>>>>> How do you think?
>>>>>
>>>>> If there is anything I misunderstood, please feel free to post here.
>>>>>
>>>>> Sincerely,
>>>>>
>>>>> Steven Cheng
>>>>>
>>>>> Microsoft MSDN Online Support Lead
>>>>>
>>>>>
>>>>>
>>>>> ==================================================
>>>>>
>>>>> Get notification to my posts through email? Please refer to
>>>>>
>> http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
>>>>> ications.
>>>>>
>>>>>
>>>>>
>>>>> Note: The MSDN Managed Newsgroup support offering is for non-urgent
>>>>> issues
>>>>> where an initial response from the community or a Microsoft Support
>>>>> Engineer within 1 business day is acceptable. Please note that each
>>>>> follow
>>>>> up response may take approximately 2 business days as the support
>>>>> professional working with you may need further investigation to reach
>> the
>>>>> most efficient resolution. The offering is not appropriate for
>> situations
>>>>> that require urgent, real-time or phone-based interactions or complex
>>>>> project analysis and dump analysis issues. Issues of this nature are
>> best
>>>>> handled working with a dedicated Microsoft Support Engineer by
>> contacting
>>>>> Microsoft Customer Support Services (CSS) at
>>>>> http://msdn.microsoft.com/subscriptions/support/default.aspx.
>>>>>
>>>>> ==================================================
>>>>>
>>>>>
>>>>> This posting is provided "AS IS" with no warranties, and confers no
>>>>> rights.
>>>>>
>>>>> --------------------
>>>>>>From: "JJ" <abc@xyz.com>
>>>>>>References: <O9U2W9dBIHA.4880@TK2MSFTNGP03.phx.gbl>
>>>>>>Subject: Re: Web Parts Instances
>>>>>>Date: Wed, 3 Oct 2007 18:44:03 +0100
>>>>>>Ok I think, or rather hope, I've gone some way to answering my own
>>>>> question.
>>>>>>
>>>>>>I've used the controls UniqueID property to establish a connection
>>>>>>between
>>>>>>the instance an a unique record in the database. From my very limited
>>>>> tests,
>>>>>>this UniqueID property doesn't seem to change if you change the
>>>>>>position
>>>>> of
>>>>>>the web part on the page, or if you add others around it, or change
>>>>>>the
>>>>>>order.
>>>>>>
>>>>>>My next quesiton is, is this uniqueID unique throughout the entire
>>>>>>site,
>>>>> or
>>>>>>do I need to add some other unique information to it (like the path to
>>>>>>the
>>>>>>current page, for instance)? I suspect I do, but would appreciate some
>>>>>>advice here...
>>>>>>
>>>>>>JJ
>>>>>>
>>>>>>
>>>>>>"JJ" <abc@xyz.com> wrote in message
>>>>>>news:O9U2W9dBIHA.4880@TK2MSFTNGP03.phx.gbl...
>>>>>>> I'm newish to web parts:
>>>>>>>
>>>>>>> Say for example I create a web part from a control that displays
>>>>>>> some
>>>>> text
>>>>>>> on a web page. The control would allow some text, which is stored in
>> an
>>>>>>> sql database, to be edited. The user could in theory add several
>>>>> instances
>>>>>>> of this web part to a page, and each instance needs to display its
>>>>> unique
>>>>>>> text as stored in the corresponding record in the database.
>>>>>>>
>>>>>>> In order to achieve this I would imagine I need to tie a web part
>>>>> instance
>>>>>>> to some sort of unique identifier. How would I do this? In other
>> words,
>>>>>>> how is it possible for different instances of the same web part to
>>>>>>> refer
>>>>>>> to unique records?
>>>>>>>
>>>>>>> Please tell me if I'm not making myself clear.
>>>>>>> JJ
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>>
>>
>
>


Steven Cheng[MSFT]
Posted: Monday, October 08, 2007 5:03:11 AM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 08/10/2007 05:03:11
Date: Mon, 08 Oct 2007 05:03:11 GMT

Hi JJ,

Yes, I have looked at the pageflake sites you provided, it seems a typical
webpart like personalizable page. And we can drag multiple instances of
StickyNote parts onto the page and type difference info into. However, when
I close the page and visit it again, I think it should regenerate the page
interface with database record. e.g. It will add two StickyNots parts onto
page again, and assign their ID as the one from database record(rather than
recalculate the ID via code), right?

Also, for such personalize page, it will surely depend on client cookie,
otherwise, the server won't know whether it is the same client that request
the page again or which personalized data should retrieve from database to
repopulate it. So cookie will play an important role here, do you think so?


Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.


>From: "JJ" <abc@xyz.com>
>Subject: Re: Web Parts Instances
>Date: Fri, 5 Oct 2007 13:57:23 +0100

>
>Better still they have a notepad 'pageflake' there (you need to 'Browse
all
>flakes' when personalizing your page), and that is exactly what I am
trying
>to create.
>
>
>
>"JJ" <abc@xyz.com> wrote in message
>news:%23jo9gZzBIHA.5752@TK2MSFTNGP02.phx.gbl...
>> Here's a small example of what I am trying to do. This site is based on
>> web parts. You can add multiple instances of the same web part on a page
>> and each web part accessed different database records. Go to this site:
>> http://www.pageflakes.com/
>>
>> And choose to Personalize your page. Now choose to add the 'Sticky Note'
>> web part, then add another one. You can see that you can type different
>> text in each web part and move the web parts around. Each web part is
>> associated with a different record stored in the database.
>>
>> This is a simplified version of what I need. This surely proves that
there
>> is a way to do this. Yes, the page information is based on a per user
>> basis, but you still have the problem of associating a particular web
part
>> with a particular database record for each user (i.e. using the username
>> as a key to finding the record is not enough).
>>
>> ??
>>
>> "Steven Cheng[MSFT]" <stcheng@online.microsoft.com> wrote in message
>> news:se9erPwBIHA.5204@TK2MSFTNGHUB02.phx.gbl...
>>> Thanks for your followup JJ,
>>>
>>> To answer the question in former messages:
>>>
>>> *Yes, GetHasCode implementation may vary between different framework
>>> version, it has opacity.
>>>
>>> *Sure, timestamp approach can only make sure you assign a new created
>>> instance a unique ID, it should be our own code logic to always
>>> associcate
>>> a given ID with a certain objecct instance(for your case, the object is
>>> Editor web part).
>>>
>>> In original messages, I haven't realized that you need to associate your
>>> editor webpart with database record. Would you provide some more
business
>>> code logic info on this? Now, what I understand is that you may have
>>> multiple editor webpart instances on a page and each of them should map
>>> to
>>> a unique record in database. And next time user open page and open new
>>> editor webparts, you need to associate them to database records
>>> again,correct?
>>>
>>> If this is the case, I'm afraid it is quite hard to archive. Because
>>> generally, the mapping sequence should be as below:
>>>
>>> ** you retrieve records from database
>>>
>>> ** you create editor webparts based on those records in databases
>>>
>>> It's quite hard to create webparts and then associate them with database
>>> records. Because you haven't any identifer for those new created
>>> webparts,
>>> right? Mostly, in web application, you may consider using current
user's
>>> identifer(if there is user authentication in your application) to
>>> uniquely
>>> identify an object. Do you think it is possible to do this in your
>>> application?
>>>
>>> Anyway, please feel free to let me know if there is still anything I
>>> missed
>>> here.
>>>
>>> Sincerely,
>>>
>>> Steven Cheng
>>>
>>> Microsoft MSDN Online Support Lead
>>>
>>>
>>> This posting is provided "AS IS" with no warranties, and confers no
>>> rights.
>>>
>>>
>>> --------------------
>>>
>>>>Subject: Re: Web Parts Instances
>>>>Date: Thu, 4 Oct 2007 14:14:56 +0100
>>>
>>>>
>>>>I'm really stuck here if anyone can help.
>>>>
>>>>I'm basically trying to create a html editor web part (not using
>>>>Sharepoint). In order to do this I need to somehow hard wire the web
part
>>>>instance (remembering that there may be more than one instance of this
>>>>web
>>>>part on any page, and that the pages url may change also due to the
>>> cms/url
>>>>rewriting) to a database record that stores the actual html.
>>>>
>>>>My problem seems to come down to:
>>>>1) how you would pick a unique identifier that could be used as a key to
>>> the
>>>>database record,
>>>>2) how you would keep this constant whenever the web part was moved,
page
>>>>url changed (via url re-writing) etc,
>>>>3) how the unique identifier would persist (if it was not somehow
>>> calculated
>>>>each time the web part loads) indefinately
>>>>
>>>>??
>>>>
>>>>Web parts seem to me to be an obvious approach to building a 'simple'
>>>>cms,
>>>>in that an 'editor' can add/remove parts via the shared scope. What I am
>>>>trying to do here is create a part that also allows them to edit what
>>>>text
>>>>is within one of the parts.
>>>>
>>>>Judging by the lack of info around on this issue, I am either doing
>>>>something that will never work, or I am missing something obvious....
>>>>
>>>>Please help if you can,
>>>>JJ
>>>>
>>>>
>>>>
>>>>"JJ" <abc@xyz.com> wrote in message
>>>>news:OEVTdemBIHA.3916@TK2MSFTNGP02.phx.gbl...
>>>>> Another thougth about the GetHashCode + Unique ID method:
>>>>> In this scenario I am building a limited CMS system. It is possible
>>>>> therefore that the URL of the page may change if its location in
>>>>> changed
>>>>> in the heirachy of the site (which will use URL rewriting). Is the
Hash
>>>>> Code based on this URL, or on some unchanging properties (like the
>>>>> filename and path from root, for example)?
>>>>>
>>>>> If its based on the re-written url, then this will change and so,
again
>>>>> the connection between the unique identifier and the database record
>>> will
>>>>> be broken...
>>>>>
>>>>> Thanks,
>>>>> JJ
>>>>>
>>>>>
>>>>> "Steven Cheng[MSFT]" <stcheng@online.microsoft.com> wrote in message
>>>>> news:RBn78BjBIHA.5204@TK2MSFTNGHUB02.phx.gbl...
>>>>>> Hi JJ,
>>>>>>
>>>>>> To answer your question first, Yes, UniqueID is a unique identifer
for
>>>>>> a
>>>>>> given control, but this is only guaranteed at page level(for this web
>>>>>> form
>>>>>> page), it help make sure that on the client-side rendered html form,
>>>>>> every
>>>>>> control won't have duplicated client identifiers.
>>>>>>
>>>>>> for your scenario, you just need to make sure each webpart control(of
>>>>>> your
>>>>>> custom one) instance has its own unique value and this value need to
>>>>>> be
>>>>>> automatically generated, correct? If so,I think you can consider the
>>>>>> following approaches:
>>>>>>
>>>>>> 1) Use the Page's "GetHashCode" to get its instance identifier and
>>>>>> then
>>>>>> combine it with your control's uniqueID(or also HashCode value) to
>>>>>> generate
>>>>>> an new identifer.
>>>>>>
>>>>>> 2) You can use the current timestamp and combine your control's ID to
>>>>>> generate an identifer
>>>>>>
>>>>>> How do you think?
>>>>>>
>>>>>> If there is anything I misunderstood, please feel free to post here.
>>>>>>
>>>>>> Sincerely,
>>>>>>
>>>>>> Steven Cheng
>>>>>>
>>>>>> Microsoft MSDN Online Support Lead
>>>>>>
>>>>>>
>>>>>>
>>>>>> ==================================================
>>>>>>
>>>>>> Get notification to my posts through email? Please refer to
>>>>>>
>>>
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
>>>>>> ications.
>>>>>>
>>>>>>
>>>>>>
>>>>>> Note: The MSDN Managed Newsgroup support offering is for non-urgent
>>>>>> issues
>>>>>> where an initial response from the community or a Microsoft Support
>>>>>> Engineer within 1 business day is acceptable. Please note that each
>>>>>> follow
>>>>>> up response may take approximately 2 business days as the support
>>>>>> professional working with you may need further investigation to reach
>>> the
>>>>>> most efficient resolution. The offering is not appropriate for
>>> situations
>>>>>> that require urgent, real-time or phone-based interactions or complex
>>>>>> project analysis and dump analysis issues. Issues of this nature are
>>> best
>>>>>> handled working with a dedicated Microsoft Support Engineer by
>>> contacting
>>>>>> Microsoft Customer Support Services (CSS) at
>>>>>> http://msdn.microsoft.com/subscriptions/support/default.aspx.
>>>>>>
>>>>>> ==================================================
>>>>>>
>>>>>>
>>>>>> This posting is provided "AS IS" with no warranties, and confers no
>>>>>> rights.
>>>>>>
>>>>>> --------------------
>>>>>>>From: "JJ" <abc@xyz.com>
>>>>>>>References: <O9U2W9dBIHA.4880@TK2MSFTNGP03.phx.gbl>
>>>>>>>Subject: Re: Web Parts Instances
>>>>>>>Date: Wed, 3 Oct 2007 18:44:03 +0100
>>>>>>>Ok I think, or rather hope, I've gone some way to answering my own
>>>>>> question.
>>>>>>>
>>>>>>>I've used the controls UniqueID property to establish a connection
>>>>>>>between
>>>>>>>the instance an a unique record in the database. From my very limited
>>>>>> tests,
>>>>>>>this UniqueID property doesn't seem to change if you change the
>>>>>>>position
>>>>>> of
>>>>>>>the web part on the page, or if you add others around it, or change
>>>>>>>the
>>>>>>>order.
>>>>>>>
>>>>>>>My next quesiton is, is this uniqueID unique throughout the entire
>>>>>>>site,
>>>>>> or
>>>>>>>do I need to add some other unique information to it (like the path
to
>>>>>>>the
>>>>>>>current page, for instance)? I suspect I do, but would appreciate
some
>>>>>>>advice here...
>>>>>>>
>>>>>>>JJ
>>>>>>>
>>>>>>>
>>>>>>>"JJ" <abc@xyz.com> wrote in message
>>>>>>>news:O9U2W9dBIHA.4880@TK2MSFTNGP03.phx.gbl...
>>>>>>>> I'm newish to web parts:
>>>>>>>>
>>>>>>>> Say for example I create a web part from a control that displays
>>>>>>>> some
>>>>>> text
>>>>>>>> on a web page. The control would allow some text, which is stored
in
>>> an
>>>>>>>> sql database, to be edited. The user could in theory add several
>>>>>> instances
>>>>>>>> of this web part to a page, and each instance needs to display its
>>>>>> unique
>>>>>>>> text as stored in the corresponding record in the database.
>>>>>>>>
>>>>>>>> In order to achieve this I would imagine I need to tie a web part
>>>>>> instance
>>>>>>>> to some sort of unique identifier. How would I do this? In other
>>> words,
>>>>>>>> how is it possible for different instances of the same web part to
>>>>>>>> refer
>>>>>>>> to unique records?
>>>>>>>>
>>>>>>>> Please tell me if I'm not making myself clear.
>>>>>>>> JJ
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>
>>
>>
>
>
>

JJ
Posted: Monday, October 08, 2007 10:59:49 AM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 08/10/2007 10:59:49
Date: Mon, 8 Oct 2007 09:59:49 +0100

Hi Steven,

Yes, the site does regenerate the stickies etc (otherwise there would be no
point in the site having such features), but you have to register in order
for your personalization to be saved.

The 'cookie' may play an important role in identifying a user (anonymous or
otherwise) but I do not see how it relates to how the webparts recalculate
their corresponding database record upon reload (even once the user is
identified).

I am sure you trying to hint to me how it is done, but I'd appreciate a bit
more information because I still do not understand?

Are you saying that Unique Identifier = pageURL(unique on the site) +
userid(unique to the user) + controlID(unique on the page), will do the job?
I guess that then I would have to re-establish any links if the user move
the page within the site hierachy and hence changes the url.
(I am nervous to use GetHashCode for the page becuase, as you say, the
algorythm for this may change as the .net framework changes.)

Does that sound like an appropriate approach, and perhpas the one you are
suggesting?

Thanks,
JJ


"Steven Cheng[MSFT]" <stcheng@online.microsoft.com> wrote in message
news:E2%23eUiWCIHA.2524@TK2MSFTNGHUB02.phx.gbl...
> Hi JJ,
>
> Yes, I have looked at the pageflake sites you provided, it seems a typical
> webpart like personalizable page. And we can drag multiple instances of
> StickyNote parts onto the page and type difference info into. However,
> when
> I close the page and visit it again, I think it should regenerate the page
> interface with database record. e.g. It will add two StickyNots parts onto
> page again, and assign their ID as the one from database record(rather
> than
> recalculate the ID via code), right?
>
> Also, for such personalize page, it will surely depend on client cookie,
> otherwise, the server won't know whether it is the same client that
> request
> the page again or which personalized data should retrieve from database to
> repopulate it. So cookie will play an important role here, do you think
> so?
>
>
> Sincerely,
>
> Steven Cheng
>
> Microsoft MSDN Online Support Lead
>
>
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
> --------------------
>>From: "JJ" <abc@xyz.com>
>>S