weixin_33694620 2011-11-03 11:28 采纳率: 0%
浏览 39

ASP.NET AJAX延迟

I'm using VS2010,C# to develop my ASP.NET web app. I have some a combo box for selecting province and another combo box for selecting cities, when user selected a province, the city combo box should immediately display cities belonging to that province. I have inserted an AJAX script manager into my page, also an AJAX update panel (both from toolbox) in which I've inserted my combo boxes. Then I enabled province combo box autopostback property so that when user changes his selection, I can detect it and change contents of city combo box accordingly. It works fine, as I load province and city names from my database into a list at page startup (of course this load process is performed in a if(!IsPostback) statement so that data is loaded only once). I think the time needed to update city combo box is a bit more than what is required, as there is a postback when user changes province combo box selection, what is the best (and correct) way of performing this operation? is it ok? are there any better ways of doing it? how can I IMMEDIATELY update city combo box after province combo box selection is changed, as currently there is a short delay.

thanks

  • 写回答

1条回答 默认 最新

  • weixin_33739523 2011-11-03 12:06
    关注

    You're always going to have a delay if you do it on the server side with an ASP.NET postback.

    Another option would be to output some JSON to your page on initial load which contains an array of all your provinces with a nested array for each province containing its respective cities.

    Then you can remove the auto postback and do everything client side with JavaScript. Whenever the selected province changes you just need to parse your JSON and add all the associated cities to the second dropdown list.

    评论

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥20 求用stm32f103c6t6在lcd1206上显示Door is open和password:
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法