Logo 
Search:

Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Help Categories in SPSv2

  Asked By: Teddy    Date: Apr 29    Category: Sharepoint    Views: 882

I tried to create a Category in SPSv2 using a aspx page
but when I run the code the application return the
following error:

"Microsoft.SharePoint.SPException: The security
validation for this page is invalid and might be
corrupted. Please use your web browser's Back button to
try your operation again."

I know that the problem is when try to execute the
addCategory method...

Private Sub BtnCreateCat_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
BtnCreateCat.Click

Const nl = "<br>" 'New line

Dim web As SPWeb = SPControl.GetContextWeb(context)
Dim icarCategory As SPSCategory = SPSCategory.GetCategory
(PortalApplication.GetContext(), web.ID)

Response.Write(icarCategory.Title & nl)

'Let me see the top level categories
Dim subc As SPSCategory
Dim listOfCat As SPSCategories = _
(icarCategory.subCategories("Categories")).subCategories

For Each subc In listOfCat
Response.Write("-->" & subc.Title & nl)
Next

Try
Dim newCat As SPSCategory = listOfCat.AddCategory
("new")

newCat.Title = "Namespaces"
newCat.AddKeyword("namespace")
newCat.Description = "a category for namespaces"
newCat.Update()
listOfCat.Update()
Response.Write("Created")
Catch ex As SPException
Response.Write("Error: " & ex.ToString() & nl)
Response.Write("Message: " & ex.Message & nl)
Response.Write("Source: " & ex.Source & nl)
Response.Write("Code: " & (ex.ErrorCode).ToString()& nl)
End Try

End Sub

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on Help Categories in SPSv2 Or get search suggestion and latest updates.




Tagged: