How to add an image to Resource gallery via progamatically
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > Microsoft Content Management Server > How to add an image to Resource gallery via progamatically




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    How to add an image to Resource gallery via progamatically  
dsen_25


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-21-05 10: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.ServerAc
countName,
"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.






[ Post a follow-up to this message ]



    Re: How to add an image to Resource gallery via progamatically  
Stefan [MSFT]


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-21-05 10: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.GetNodeFromInd
ex(UserMenuLocalTree.SelectedNodeIndex).ID())
>
>                Dim AppContext As CmsApplicationContext = New
> CmsApplicationContext
> (Microsoft.ContentManagement.Publishing.CmsHttpContext.Current.User.Server
AccountName,
> "abc@123", PublishingMode.Update)
>
>
>
> 'AppContext. AuthenticateAsCurrentUser(PublishingMode
.Update)
>                Dim gallery As ResourceGallery =
> CmsHttpContext.Current.Searches.GetByGuid(UserMenuLocalTree.GetNodeFromInd
ex(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.
>







[ Post a follow-up to this message ]



    re:How to add an image to Resource gallery via progamatically  
dsen_25


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-22-05 12:49 PM

Thanks.Now it is working.






[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 07:10 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register