惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园_首页
Microsoft Security Blog
Microsoft Security Blog
云风的 BLOG
云风的 BLOG
B
Blog
The Register - Security
The Register - Security
L
LangChain Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
N
Netflix TechBlog - Medium
F
Full Disclosure
The GitHub Blog
The GitHub Blog
Recorded Future
Recorded Future
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Blog — PlanetScale
Blog — PlanetScale
Jina AI
Jina AI
美团技术团队
宝玉的分享
宝玉的分享
Hugging Face - Blog
Hugging Face - Blog
阮一峰的网络日志
阮一峰的网络日志
G
Google Developers Blog
大猫的无限游戏
大猫的无限游戏
S
SegmentFault 最新的问题
D
DataBreaches.Net
Martin Fowler
Martin Fowler
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Google DeepMind News
Google DeepMind News
WordPress大学
WordPress大学
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - Franky
The Cloudflare Blog
博客园 - 【当耐特】
U
Unit 42
月光博客
月光博客
T
The Blog of Author Tim Ferriss
博客园 - 叶小钗
博客园 - 聂微东
I
InfoQ
B
Blog RSS Feed
Apple Machine Learning Research
Apple Machine Learning Research
Cyberwarzone
Cyberwarzone
V
V2EX
S
Securelist
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
S
Security @ Cisco Blogs
PCI Perspectives
PCI Perspectives
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
H
Heimdal Security Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
The Hacker News
The Hacker News
D
Darknet – Hacking Tools, Hacker News & Cyber Security
T
Tor Project blog

博客园 - cean

MSSQL 2005删除所有表的语句[转] MSSQL 2000更改表和存储过程的所有者 C#的String.Split方法[转] StreamReader读取记事本 - cean - 博客园 表中随机查询记录 几种基本的数字正则表达式[转] 浅谈window.attachEvent [转] 在.ashx文件下使用session[转] - cean - 博客园 典文回顾:程序员规划职业道路时需考虑的十个问题[转CSDN] 水印坐标设置 [转]HTML 编辑器大全 [转]Asp.net(Ajax)表单验证 函数包 母版页判断登陆 及 母版页与内容页的执行顺序 - cean [转]SQL2000和SQL2005同时安装问题 C#泛型详解[转] .Net课堂:总结必须学习的10项.NET技术[转] 如何建立最初的三层架构[转] 运行asp.net时弹出the status code returned from the server was:404错误提示 iis5.1配置php运行环境
关于使用updatepanle后页面还会刷新的个人解决方法。 - cean - 博客园
cean · 2009-06-18 · via 博客园 - cean

之间做了个页面,页面上放的控件有:两个label/button/DropDownList/updatepanle/scriptManage,想要实现的功能是根据DropDownList选择的值来动态的更新lblDrp的值。

以下是我的代码:aspx

现在的时间是:<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
        <asp:Button ID="Button1" runat="server" Text=" 更新时间" />
        <br />
        <br />
       
        <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true"
            onselectedindexchanged="DropDownList1_SelectedIndexChanged">
            <asp:ListItem>兔子</asp:ListItem>
            <asp:ListItem>老虎</asp:ListItem>
            <asp:ListItem>猴子</asp:ListItem>
                </asp:DropDownList>
               
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <Triggers>
                <asp:AsyncPostBackTrigger ControlID="DropDownList1" EventName="SelectedIndexChanged" />
            </Triggers>
            <ContentTemplate>
                <asp:Label ID="Label2" runat="server" Text="Labe2"></asp:Label>
            </ContentTemplate>
           
           
        </asp:UpdatePanel>

=============

aspx.cs代码:
    protected void Page_Load(object sender, EventArgs e)
    {

        Label1.Text = DateTime.Now.ToString();
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        Label2.Text = DateTime.Now.ToString();
    }

    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        Label2.Text = DropDownList1.SelectedItem.ToString();
    }

==================如果单独复制上面的代码到文件中,会发现选择DropDownList后,页面并不是局部刷新,这时要在web.config中加入以下代码:

<httpHandlers>
      <remove verb="*" path="*.asmx"/>
      <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
    </httpHandlers>

=============

如果加入后还是会出现刷新整个页面的情况,这时查找下web.config中是否有:<xhtmlConformance mode="Legacy"/>配置,把它删除就可以实现局部刷新的效果了,当时我在新建的项目中按以上步骤可以实现局部刷新,但是在另外的网站中并不能实现,通过删除web.config中的<xhtmlConformance mode="Legacy"/>后,发现正常了。查了MSDN,说xhtmlcomformance是配置符合 XHTML 1.0 的控件呈现,我也不懂为什么加入这个配置会导致updatepanle不能使用。

另外之前查网络上的资料说是出现会刷新整个页面的情况时,要把DropDownList控件和显示的都要放到ContentTemplate中,个人觉得放在外面比较方便,而且也能实现。哈。文笔不好。见谅。。