当前位置:编程学习 > C#/ASP.NET >>

Silverlight中POST请求一般处理程序类问题

     小弟刚学SL,现在在数据绑定这里遇到问题,请教各位大大,其中:lb_Books是listBox

            WebRequest request = asyncResult.AsyncState as WebRequest;
            Stream stream = request.EndGetRequestStream(asyncResult);
            StreamWriter sw = new StreamWriter(stream);
           // sw.Write(string.Format("No={0}",lb_Books.SelectedIndex.ToString()));//这样写直接报跨线程访问无效
            sw.Write(string.Format("No={0}", new GetValue(GetVal)));//这种自定义委托实现
            sw.Flush();
            sw.Close();
            sw.Dispose();
            stream.Close();
            stream.Dispose();
//以下是委托部分:
private delegate string GetValue();
        private string GetVal()
        {
            return lb_Books.SelectedIndex.ToString();
        }

//ashx中,在获取提交的No时,得到时数据:
context.Request.Form["No"]
结果:"SilverLightControl.SilverlightControl GetValue"本来应该获取的是lb_Books选中的索引值
context.Response.Write(context.Request.Form["No"]);
--------------------编程问答-------------------- 跪求啊。。。
补充:.NET技术 ,  .NET技术前瞻
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,