none
Sharepoint lIst=>Silverlight Ui(Quiz Application)

    Pertanyaan

  • i have a list named Questions. have following fields


    QuestionNumber
    Question
    AnswerA
    AnswerB
    AnswerC

    AnswerD        CorrectAnswer

    Use SHIFT+ENTER to open the menu (new window).

    i have designed my GUI in Silverlight.

    What i want is to fetch 1 question at a time and its options. When i will press "Next" button it  must fetch next question from list.

    Please do reply asap!!!!

    As i m new in this Sharepoint please elaborate the code!!!!!

    09 Juli 2012 11:11

Jawaban

Semua Balasan

  • Hello ,

    you can use the below link to fetch the data using silver light,

    http://stackoverflow.com/questions/10930616/silverlight-webpart-get-list-items.

    1) Once all the data retrieved you can use the session or viewstate object to store the all the value

        (e.g store the ListItemCollection value in ViewState or Session Variable) lets named it as "AllQuestions"

    2) Now you need to track the current question using the another Session or ViewState Object lets named it as "CurrentQuestion".

    3) So implementation logic like if when the page is loading and value of "CurrentQuestion" is null , so that mean you need to display the first question by using the value from the "AllQuestions" and you need to store the "CurrentQuestion" value 1 in the Session or ViewState.

    4)Next time when you click on the next button you need to check the "CurrentQuestion" value , if it does not null ,so increment it by 1 and fetch that incremented record from the "AllQuestions" and save the incremented value in the "CurrentQuestion" again in the ViewState or Session object.

    5)Next follow the same procedure.

    Hope this will helpful to you.



    Hiren Patel | Please click "Propose As Answer" if this post solves your problem or "Vote As Helpful" if this post has been useful to you.


    10 Juli 2012 6:59
  • Still not working!!!!!!I took silverlight  navigation Application. it gives me a master page like look so i picked it.

    Does it make any wrong about code????If not then what goes wrong with this code

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;
    using System.Windows.Navigation;
    using Microsoft.SharePoint.Client;
    using SP = Microsoft.SharePoint.Client;


    namespace QuizNav.Views
    {
        public partial class Test : Page
        {
            private IEnumerable<ListItem> ldata = null;
            SP.ClientContext clientContext;
            string siteURL = "xxxxxx";
            Web web;

            public Test()
            {
                InitializeComponent();

               
                clientContext = new ClientContext(siteURL);
               // clientContext = ClientContext.Current;
                web = clientContext.Web;
                clientContext.Load(web);
                List quizlist = web.Lists.GetByTitle("Questions");

                CamlQuery query = CamlQuery.CreateAllItemsQuery();

                ListItemCollection listitems = quizlist.GetItems(query); 
                clientContext.Load(listitems);
                clientContext.ExecuteQueryAsync(succeededCallback, failedCallback);            

            }


            // Executes when the user navigates to this page.
            protected override void OnNavigatedTo(NavigationEventArgs e)
            {
            }

            private void succeededCallback(object sender, ClientRequestSucceededEventArgs e)
            {

                DisplayInfo();         
               
            }

            private void DisplayInfo()
            {
                foreach (ListItem listitems in listitem)
                {
                    lblquestion.Content += listitems.FieldValues["Question"].ToString();
                    radioButton1.Content += listitems.FieldValues["AnswerA"].ToString();
                    radioButton2.Content += listitems.FieldValues["AnswerB"].ToString();
                    radioButton3.Content += listitems.FieldValues["AnswerC"].ToString();
                    radioButton4.Content += listitems.FieldValues["AnswerD"].ToString();
                }
            }

            private void failedCallback(object sender, ClientRequestFailedEventArgs f)
            {
                this.Dispatcher.BeginInvoke(() =>
                {
                    MessageBox.Show("Error!!!!!!");
                });
            }


            int minute = 29;
            int second = 60;

            public void Each_Tick(object o, EventArgs sender)
            {

                textBlock1.Text = minute.ToString();
                textBlock2.Text = second.ToString();
                if (second == 1)
                {
                    textBlock1.Text = minute.ToString();
                    minute = minute - 1;
                    second = 60;

                }
                else
                {
                    second = second - 1;
                    textBlock2.Text = second.ToString();

                }
            }


            private void btnprevious_Click(object sender, RoutedEventArgs e)
            {

            }

            private void btnnext_Click(object sender, RoutedEventArgs e)
            {

            }

            private void btnstart_Click(object sender, RoutedEventArgs e)
            {

            }

            private void button1_Click(object sender, RoutedEventArgs e)
            {

            }






            public IEnumerable<ListItem> listitem { get; set; }
        }
    }

    10 Juli 2012 10:38
  • Hi nirajzambad,

    I suggest you debug your code and find where caused your issue.
    For more information, please refer to the following links:
    Create a Silverlight 4 Web Part for SharePoint 2010:http://msdn.microsoft.com/en-us/magazine/ff956224.aspx
    Silverlight and SharePoint Integration:http://msdn.microsoft.com/en-us/library/gg701782.aspx
    Debug silverlight webpart:http://social.technet.microsoft.com/Forums/en-US/sharepoint2010programming/thread/49b6a5e3-e929-46a2-af15-36bb7dc722dd/

    Thanks,
    Lhan Han
    16 Juli 2012 8:17
    Moderator