Tell me more ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

This may be more of a Silverlight issue than a SharePoint issue, but in the following VB code which adds items to a SharePoint list, I would expect to get two pop-ips ("Person added" and "Finished") when submit is pressed.

Does anybody know why I don't? I must admit to not entirely understanding the whole Duspatcher/updateUI part which I have cribbed from code examples.

Thanks,

Jason.

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
share|improve this question
Anyone have any ideas on this? Thanks. – finisterre Nov 8 '12 at 19:48

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.