首页 新闻 会员 周边

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

0
悬赏园豆:10 [待解决问题]

小弟刚学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"]);
MyDreams的主页 MyDreams | 初学一级 | 园豆:72
提问于:2011-10-10 23:17
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册