silverlight应用:使用SilverLight构建插件式应用程序( 7)

  留言板插件添加:

使用SilverLight构建插件式应用<img src='/icons/62860chengxu.gif' />( 7)

  这是个添加留言部分:代码比较简单:

 //留言对象
      NotesInfo ni = NotesInfo;
      ni.UserName = UserName;
      ni.Title = this.txtTitle.Text;
      ni.Content = this.txtContent.Text;
      //服务路径
      Uri uri = .Windows.Browser.HtmlPage.Document.DocumentUri;
       host = uri.AbsoluteUri;
      host = host.Sub(0, host.Length - uri.LocalPath.Length);
       servicePath = "/Services/WSNotes.svc";
       serviceUri = host + servicePath;
      //构建服务开始保存
      WSNotesClient ws = WSNotesClient( .ServiceModel.BasicHttpBinding, .ServiceModel.EndpoAddress(serviceUri));
      ws.InsertNotesCompleted EventHandler<InsertNotesCompletedEventArgs>(ws_InsertNotesCompleted);
      ws.InsertNotesAsync(ni);


  保存完成的后通知显示界面重新刷新数据

 void ws_InsertNotesCompleted(object sender, InsertNotesCompletedEventArgs e)
    {
       (e.Error null)
      {
         (e.Result)
        {
           (OnSaveed != null)
          {
            OnSaveed(this, true);
          }
        }
      }
    }


  这样数据就可以立即显示当前用户输入数据同时避免用户多次提交相同数据问题

  下步是做个即时聊天然后是做个国际象棋在线对战平台欢迎对sl有兴趣朋友加入

  预览:www.cuface.cn

Tags:  silverlight.2.0 silverlight是什么 silverlight silverlight应用

延伸阅读

最新评论

发表评论