• 用ajax异步请求一个块


    使用用户控件,作为一个块,生成一段独立的html。

    请求一个一般应用程序,在一般应用程序中加载读取用户控件,并给用户控件传值。

             Page page = new Page();
               
                div1 ctl = (div1)page.LoadControl("div1.ascx");
                ctl.Id = "1";//给用户控件传递参数
     
                page.Controls.Add(ctl);
                StringWriter writer = new StringWriter();
                HttpContext.Current.Server.Execute(page, writer, false);
                context.Response.Write(writer.ToString());


    这样就可以异步请求一个块了。


    这是老赵的博客中用用户控件生成的html的例子。
    public class GetComments : IHttpHandler
    {
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
     
            ViewManager<ItemComments> viewManager = new ViewManager<ItemComments>();
            ItemComments control = viewManager.LoadViewControl("~/ItemComments.ascx");
     
            control.PageIndex = Int32.Parse(context.Request.QueryString["page"]);
            control.PageSize = 3;
     
            context.Response.Write(viewManager.RenderView(control));
        }
     
        public bool IsReusable { ... }
    } 
  • 相关阅读:
    双向(端)链表、栈、队列
    WPF 3D基础(1)
    静态查找
    栈和队列 迷宫求解
    异步编程Demo
    WPF 3D基础(2)
    串操作
    链栈和链队
    Linux恢复数据
    word文件修复窍门
  • 原文地址:https://www.cnblogs.com/Tpf386/p/7608258.html
Copyright © 2020-2023  润新知