The VB code below works in a stand-alone Silverlight app to add new items to a pre-existing list, but when I include it in a larger app it doesn't.
The only difference I can see is that with the standalone app MainPage.xaml.vb has INHERITS USERCONTROL and with the larger app Page2.xaml.vb has INHERITS PAGE.
Would this make a difference?
Thanks,
JT
Imports Microsoft.SharePoint.Client
Partial Public Class MainPage
Inherits UserControl
Public Sub New()
InitializeComponent()
End Sub
Private Sub onAddSucceeded(ByVal sender As Object, ByVal args As ClientRequestSucceededEventArgs)
MessageBox.Show("Person Added")
Dim updateUI As UpdateUIMethod = AddressOf DisplayInfo
Me.Dispatcher.BeginInvoke(updateUI)
End Sub
Private Sub onAddFailed(ByVal sender As Object, ByVal args As ClientRequestFailedEventArgs)
MessageBox.Show("Epic Fail!" & args.Message & vbLf & args.StackTrace)
End Sub
Private Sub DisplayInfo()
MessageBox.Show("Finished")
End Sub
Private Delegate Sub UpdateUIMethod()
Private Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button1.Click
Dim clientContext As ClientContext = clientContext.Current
Dim oList As List = clientContext.Web.Lists.GetByTitle("pfa")
Dim itemCreateInfo As New ListItemCreationInformation()
Dim oListItem As ListItem = oList.AddItem(itemCreateInfo)
oListItem("FullName") = TextBox1.Text
oListItem("Role") = TextBox2.Text
oListItem("Length") = TextBox3.Text
oListItem.Update()
clientContext.ExecuteQueryAsync(AddressOf OnAddSucceeded, AddressOf OnAddFailed)
End Sub
End Class