zoukankan      html  css  js  c++  java
  • 用户控件后台加载

    1 实现功能:多城市项目,某城市上线新功能,另外一部分城市维持老的用户控件,

    2 之前写法是这样,后跟踪发现,北京的仍然走了用户控件的代码,也就是用户控件已经在页面上了,还是要走一遍后台加载一遍的,这一步是浪费的。

    3 解决方法:a 页面改成PlaceHolder,后台动态加载(注意:LoadControl()方法里面的路径写项目实际路径,可能和命名空间不一致)

    b 还有一种讨巧的方法,在用户控件里面page_load判断是北京,this.visible=false,return;即虽然仍走了控件,但是直接就出来了。

      <!-- start-->
    <div id="div_inte"></div>
    <%if (cityName != "北京")
     {%>
    <uc:interested runat="Server" id="ucinterested">
    </uc:interested>
    <% }else{ %>
    <!--#include virtual="/gaa/aa.htm"-->
    <% }%>
    <!-- end-->
     <!-- start-->
                    <div id="InterestedHouse"></div>
                     <%if (cityName != "北京")
                     {%>
                     <asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
                    <% }else{ %>
                    <!--#include virtual="/aa/aa.htm"-->
                    <% }%>
                    <!-- end-->  
    protected UserControl.Detail.housedetail.interested ucinterested=new UserControl.Detail.housedetail.interested (); if (cityName != "北京") { ucinterested = (UserControl.Detail.housedetail.interested)LoadControl("/EsfHouse/UserControl/Detail/interested.ascx"); PlaceHolder1.Controls.Add(ucinterested); ucinterested.projname = ahse.PROJNAME; ucinterested.purpose = ahse.PURPOSE; ucinterested.room = ahse.ROOM.ToString(); ucinterested.district = ahse.DISTRICT; ucinterested.comarea = ahse.COMAREA; ucinterested.houseid = ahse.HOUSEID.ToString(); } else { }
  • 相关阅读:
    前端 CSS 与HTML 学习笔记详细讲解
    Python-Django之DRF
    Flask
    flask
    Python
    Python爬虫
    前端开发规范
    为什么 [] == ![] 输出是true?
    javascript准确判断各种数据类型
    JavaScript数组扁平化常用方法总结
  • 原文地址:https://www.cnblogs.com/judy0605/p/2599695.html
Copyright © 2011-2022 走看看