|
Home > Archive > Microsoft Content Management Server > June 2005 > add custom properties values by code
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
add custom properties values by code
|
|
|
| hi, i have a CMS 2002 application, andi created a template with 2
custom properties, which i use to do a search on all my postings.
i created them as "SelectionCustomProperties" and my user has to pick
up the right value for the property from a combobox in the page
properties section.
Then i use this property in another page to make a search on the
postings.
is there a way i can let my user (the site administrator) to add
possible values to that property from the page? without having to use
the visual studio .net development environment?
thank you very much
Eli
| |
| Stefan [MSFT] 2005-06-27, 5:51 pm |
| Hi Eli,
that is possible.
Use the AddAllowedValue method of the custom property definition to add a
new value.
Be aware that the user needs to have TemplateDesigner rights to do this.
Cheers,
Stefan
--
This posting is provided "AS IS" with no warranties, and confers no rights
New to MCMS?
Check out this book: Building Websites Using MCMS: http://tinyurl.com/6zj44
----------------------
"Eli_b" <elibravs@gmail.com> wrote in message
news:1119850941.924458.52840@g44g2000cwa.googlegroups.com...
> hi, i have a CMS 2002 application, andi created a template with 2
> custom properties, which i use to do a search on all my postings.
>
> i created them as "SelectionCustomProperties" and my user has to pick
> up the right value for the property from a combobox in the page
> properties section.
>
> Then i use this property in another page to make a search on the
> postings.
>
> is there a way i can let my user (the site administrator) to add
> possible values to that property from the page? without having to use
> the visual studio .net development environment?
>
> thank you very much
>
> Eli
>
| |
|
| thank you very much Stefan,
at first i was trying this code:
Posting p=CmsHttpContext.Current.Posting;
if(p.Template.CustomPropertyDefinitions["Zona"] != null)
{
p.Template.CustomPropertyDefinitions["Zona"].AddAllowedValue(txtAddZona.Text);
p.Template.Submit();
}
but then i got an error saying that i had to be in update mode, so i
looked around in another posting of this forum, and fount this
solution:
string GUID=CmsHttpContext.Current.Posting.Guid;
CmsApplicationContext cmsApp= new CmsApplicationContext();
cmsApp. AuthenticateAsCurrentUser(PublishingMode
.Update);
Posting p=(Posting)cmsApp.Searches.GetByGuid(GUID);
if(p.Template.CustomPropertyDefinitions["Zona"] != null)
{
p.Template.CustomPropertyDefinitions["Zona"].AddAllowedValue(txtAddZona.Text);
p.Template.Submit();
}
but now i get an error that the login failed and it cannot update my
template.
now im lost...
can you help me?
thank you very much
Eli
| |
| Stefan [MSFT] 2005-06-27, 5:51 pm |
| Hi Eli,
AuthenticateAsCurrentUser cannot be used in a web application. See here for
details and workaround:
http://download.microsoft.com/downl...6a/MCMS+2002+-+(complete)+FAQ.htm#7CE850B8-0F5A-4570-B8E7-3627A65E9056
Cheers,
Stefan
--
This posting is provided "AS IS" with no warranties, and confers no rights
New to MCMS?
Check out this book: Building Websites Using MCMS: http://tinyurl.com/6zj44
----------------------
"Eli_b" <elibravs@gmail.com> wrote in message
news:1119883568.751479.133950@f14g2000cwb.googlegroups.com...
> thank you very much Stefan,
> at first i was trying this code:
>
> Posting p=CmsHttpContext.Current.Posting;
>
> if(p.Template.CustomPropertyDefinitions["Zona"] != null)
> {
>
> p.Template.CustomPropertyDefinitions["Zona"].AddAllowedValue(txtAddZona.Text);
> p.Template.Submit();
> }
>
> but then i got an error saying that i had to be in update mode, so i
> looked around in another posting of this forum, and fount this
> solution:
>
> string GUID=CmsHttpContext.Current.Posting.Guid;
> CmsApplicationContext cmsApp= new CmsApplicationContext();
> cmsApp. AuthenticateAsCurrentUser(PublishingMode
.Update);
> Posting p=(Posting)cmsApp.Searches.GetByGuid(GUID);
>
> if(p.Template.CustomPropertyDefinitions["Zona"] != null)
> {
>
> p.Template.CustomPropertyDefinitions["Zona"].AddAllowedValue(txtAddZona.Text);
> p.Template.Submit();
> }
>
> but now i get an error that the login failed and it cannot update my
> template.
>
> now im lost...
>
> can you help me?
>
> thank you very much
>
> Eli
>
| |
|
| thank you very much, its going better now..
i ended up asking for the user name and password when the user wants to
add the property so i can authenticate it in my application.
its not a very confortable solution for my user, but it will do for
now.
but now, i have another problem.
To set the value of this properties im using your code
"PropertyAuthoringServerControl.cs"
i think it works great!!
but how can i rebind the control? so it will fill the combo again,
including the allowed value i just added?
thank you very very much
Eli
| |
| Stefan [MSFT] 2005-06-27, 5:51 pm |
| Hi Eli,
the only way to achieve this is to do a Response.Redirect to the current
URL.
This will reload the property values.
Or - if you need to preserve the viewstate - to generate a client side
javascript that run a post again.
Cheers,
Stefan
--
This posting is provided "AS IS" with no warranties, and confers no rights
New to MCMS?
Check out this book: Building Websites Using MCMS: http://tinyurl.com/6zj44
----------------------
"Eli_b" <elibravs@gmail.com> wrote in message
news:1119893966.427786.194180@g49g2000cwa.googlegroups.com...
> thank you very much, its going better now..
>
> i ended up asking for the user name and password when the user wants to
> add the property so i can authenticate it in my application.
>
> its not a very confortable solution for my user, but it will do for
> now.
> but now, i have another problem.
>
> To set the value of this properties im using your code
> "PropertyAuthoringServerControl.cs"
> i think it works great!!
> but how can i rebind the control? so it will fill the combo again,
> including the allowed value i just added?
>
> thank you very very much
>
> Eli
>
|
|
|
|
|