|
Home > Archive > Microsoft Content Management Server > September 2005 > How to add an image to Resource gallery via progamatically
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 |
How to add an image to Resource gallery via progamatically
|
|
| dsen_25 2005-09-21, 5:52 pm |
| Dim gallery As ResourceGallery =
CmsHttpContext.Current.Searches.GetByGuid(UserMenuLocalTree.GetNodeFromIndex(UserMenuLocalTree.SelectedNodeIndex).ID())
Dim AppContext As CmsApplicationContext = New
CmsApplicationContext
(Microsoft.ContentManagement.Publishing.CmsHttpContext.Current.User.ServerAccountName,
"abc@123", PublishingMode.Update)
'AppContext. AuthenticateAsCurrentUser(PublishingMode
.Update)
Dim gallery As ResourceGallery =
CmsHttpContext.Current.Searches.GetByGuid(UserMenuLocalTree.GetNodeFromIndex(UserMenuLocalTree.SelectedNodeIndex).ID())
If gallery.CanCreateResources Then
gallery.CreateResource(txtMainImg.PostedFile.FileName)
Else
errMsg = "cant't create"
End If
*******************
when i execute above code i got access denied error.how to solve that
error. Any one pls help me.
| |
| Stefan [MSFT] 2005-09-21, 5:52 pm |
| Hi,
you have created an applicaiton context in update mode but you are trying to
upload the item using the CmsHttpContext which is most likely not in update
mode.
That will not work.
You need to retrieve the gallery using the application context and not using
the CmsHttpContext then the upload will work.
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
----------------------
"dsen_25" <dsen_25@yahoo-dot-com.no-spam.invalid> wrote in message
news:TOadnUml47uhyqzeRVn_vA@giganews.com...
> Dim gallery As ResourceGallery =
> CmsHttpContext.Current.Searches.GetByGuid(UserMenuLocalTree.GetNodeFromIndex(UserMenuLocalTree.SelectedNodeIndex).ID())
>
> Dim AppContext As CmsApplicationContext = New
> CmsApplicationContext
> (Microsoft.ContentManagement.Publishing.CmsHttpContext.Current.User.ServerAccountName,
> "abc@123", PublishingMode.Update)
>
>
>
> 'AppContext. AuthenticateAsCurrentUser(PublishingMode
.Update)
> Dim gallery As ResourceGallery =
> CmsHttpContext.Current.Searches.GetByGuid(UserMenuLocalTree.GetNodeFromIndex(UserMenuLocalTree.SelectedNodeIndex).ID())
> If gallery.CanCreateResources Then
>
> gallery.CreateResource(txtMainImg.PostedFile.FileName)
> Else
> errMsg = "cant't create"
> End If
>
> *******************
>
> when i execute above code i got access denied error.how to solve that
> error. Any one pls help me.
>
| |
| dsen_25 2005-09-22, 7:49 am |
| Thanks.Now it is working.
|
|
|
|
|