下面是我做的一个例子,因为要用在毕设里,我先做了个实验,代码如下,但是在按了Button后,发现页面还是全部都刷新了。不知是为什么?
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" >
    </asp:ScriptManager>
     <asp:UpdatePanel ID="UpdatePanel1" runat="server">
     <ContentTemplate>
     <fieldset>
     <asp:Label ID="labN" runat="server" Style="z-index: 100; left: 100px; position: absolute;top: 63px" Text="Label"></asp:Label>
    <asp:Button ID="Button1" runat="server" Style="z-index: 102; left: 141px; position: absolute;top: 63px" Text="Button" OnClick="Button1_Click1" />
    </fieldset> 
    </ContentTemplate>                       
    </asp:UpdatePanel>                
    </form>  
</body>
这是.cs后台文件里Button键的事件。
 protected void Button1_Click1(object sender, EventArgs e)
    {
        labN.Text = "Hello";
    }

解决方案 »

  1.   

    代码无问题
    鉴定完毕
    发你完整代码,看你webConfig的配置
      

  2.   

    估计是 web.config 问题
    你建立的是 ajax 工程??
      

  3.   

    毕业设计,要求做一个网站,我做了一个仿chinaren一样的登录界面,现在就是在登录的时候已经可以实现无刷新验证了,就是在现实欢迎界面的时候有点问题。我想用这个PANEL做一个欢迎的界面。但是一点就刷新。至于完整的代码,我也是新手,做的老乱啦。怕到时候各位头都大了。WEB.CONFIG的配置我放出来了,看看大家有什么能帮助我的就谢谢啦
    <?xml version="1.0"?>
    <!-- 
        注意: 除了手动编辑此文件以外,您还可以使用 
        Web 管理工具来配置应用程序的设置。可以使用 Visual Studio 中的
         “网站”->“Asp.Net 配置”选项。
        设置和注释的完整列表在 
        machine.config.comments 中,该文件通常位于 
        \Windows\Microsoft.Net\Framework\v2.x\Config 中
    -->
    <configuration>
    <appSettings/>
    <connectionStrings>
    <add name="constr" connectionString="Server=LocalHost;Database=Trip_User;uid=sa;pwd=911"/>
    <add name="Trip_Team" connectionString="Data Source=PET;Initial Catalog=Trip_Team;Persist Security Info=True;User ID=sa;Password=911" providerName="System.Data.SqlClient"/>
    <add name="teamstr" connectionString="Server=LocalHost;Database=Trip_Team;uid=sa;pwd=911"/>
    </connectionStrings>
    <system.web>
    <httpHandlers>
    <add verb="POST,GET" path="ajaxpro/*.ashx" type="AjaxPro.AjaxHandlerFactory,AjaxPro"/>
    </httpHandlers>
    <!-- 
                设置 compilation debug="true" 将调试符号插入
                已编译的页面中。但由于这会 
                影响性能,因此只在开发过程中将此值 
                设置为 true。
            -->
    <compilation debug="true">
    <assemblies>
    <add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></assemblies></compilation>
    <!--
                通过 <authentication> 节可以配置 ASP.NET 使用的 
                安全身份验证模式,
                以标识传入的用户。 
            -->
    <authentication mode="Windows"/>
    <!--
                如果在执行请求的过程中出现未处理的错误,
                则通过 <customErrors> 节可以配置相应的处理步骤。具体说来,
                开发人员通过该节可以配置
                要显示的 html 错误页
                以代替错误堆栈跟踪。        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
                <error statusCode="403" redirect="NoAccess.htm" />
                <error statusCode="404" redirect="FileNotFound.htm" />
            </customErrors>
            -->
    </system.web>
    </configuration>
      

  4.   

    应该是webconfig问题,建立一般的asp.net网站,用它自动生成的webconfig是不能直接通过ScriptManager和UpdatePanel实现局部刷新的。需要更改webconfig设置,或者安装了ajax asp.net的扩展包后,直接建立ajax asp.net enabled网站,这样才可以哒
      

  5.   

    那这样吧,也不让大家白忙,用JAVASCRIPT脚本怎么将原来PANEL的VISIBLE属性为FALSE的设置成TRUE啊?实在不行我先用这个顶一点嘿嘿
      

  6.   

    你的整个页面都在  UpdatePanel   里啊,刷新的部分是:<asp:UpdatePanel   ID="UpdatePanel1"   runat="server">
              <ContentTemplate>
              <fieldset>
              <asp:Label   ID="labN"   runat="server"   Style="z-index:   100;   left:   100px;   position:   absolute;top:   63px"   Text="Label"> </asp:Label>
            <asp:Button   ID="Button1"   runat="server"   Style="z-index:   102;   left:   141px;   position:   absolute;top:   63px"   Text="Button"   OnClick="Button1_Click1"   />
            </fieldset>  
            </ContentTemplate>                                              
            </asp:UpdatePanel>   当刷新时,整个页面的都会有闪动,是正确的啊!因为你的页面中没有其它的东西啊!
      

  7.   

    UpdatePanel 的triggers属性写了吗,还有updatemode改成conditional
      

  8.   


    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
    <ContentTemplate>&nbsp;<asp:DropDownList ID="ddlUNITID2" runat="server">
    </asp:DropDownList></ContentTemplate>
    <Triggers><asp:AsyncPostBackTrigger  EventName="SelectedIndexChanged" ControlID="ddlUNITID"/></Triggers> </asp:UpdatePanel>
      

  9.   

    UpdatePanel:该控件需要设置一个属性值为true.属性名字我忘记了,你自己试试
      

  10.   

    希望一开始建立项目的时候就建立AJAX项目 如果是Application的话就要手工配置Web.config了
    下面是我的Web.config 仔细看看对照下 应用的程序集 应该没有问题的<?xml version="1.0" encoding="utf-8"?>
    <!-- 
        注意: 除了手动编辑此文件以外,您还可以使用 
        Web 管理工具来配置应用程序的设置。可以使用 Visual Studio 中的
         “网站”->“Asp.Net 配置”选项。
        设置和注释的完整列表在 
        machine.config.comments 中,该文件通常位于 
        \Windows\Microsoft.Net\Framework\v2.x\Config 中
    -->
    <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
      <configSections>
        <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
          <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
            <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
            <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
              <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere"/>
              <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
              <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
            </sectionGroup>
          </sectionGroup>
        </sectionGroup>
      </configSections>
      
      
      <!--server=58.215.84.226;database=fourou;uid=fourou;pwd=851123-->
      <!--Data Source=.Initial Catalog=WebShop;Integrated Security=True-->
      <connectionStrings>
        <add name="WebShopConnectionString" connectionString="Data Source=.;Initial Catalog=WebShop;Integrated Security=True"
          providerName="System.Data.SqlClient" />
      </connectionStrings>  <appSettings>
        <add key="FCKeditor:BasePath" value="~/FCKeditor/" />
        <add key="FCKeditor:UserFilesPath" value="/WebShop2.0/UserFiles"/>
      </appSettings>
      <system.web>    <pages>
          <controls>
            <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
          </controls>
        </pages>
        <!--
              Set compilation debug="true" to insert debugging
              symbols into the compiled page. Because this
              affects performance, set this value to true only
              during development.
        -->    <anonymousIdentification enabled="true"/>
        <!-- 
                设置 compilation debug="true" 将调试符号插入
                已编译的页面中。但由于这会 
                影响性能,因此只在开发过程中将此值 
                设置为 true。
            -->
        <compilation debug="true" defaultLanguage="c#">
          <assemblies>
            <add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
            <add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add assembly="System.Web.Extensions.Design, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
          </assemblies>
        </compilation>
        <!--
                通过 <authentication> 节可以配置 ASP.NET 使用的 
                安全身份验证模式,
                以标识传入的用户。 
            -->
        <authentication mode="Forms"/>
        <!--
                如果在执行请求的过程中出现未处理的错误,
                则通过 <customErrors> 节可以配置相应的处理步骤。具体说来,
                开发人员通过该节可以配置
                要显示的 html 错误页
                以代替错误堆栈跟踪。        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
                <error statusCode="403" redirect="NoAccess.htm" />
                <error statusCode="404" redirect="FileNotFound.htm" />
            </customErrors>
           
           -->
        <customErrors mode="RemoteOnly" defaultRedirect="Error.aspx">
          <error statusCode="403" redirect="NoAccess.htm" />
          <error statusCode="404" redirect="FileNotFound.htm" />
        </customErrors>    <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>
        <httpModules>
          <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
        </httpModules>  </system.web>  <system.webServer>
        <validation validateIntegratedModeConfiguration="false"/>
        <modules>
          <add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
        </modules>
        <handlers>
          <remove name="WebServiceHandlerFactory-Integrated"/>
          <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
          <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
          <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
        </handlers>
      </system.webServer>
    </configuration>
      

  11.   

    可是已经来不及啦。明天就要交了,哎。至于上面朋友说的TRIGGER我也试了,也是一点就全刷新了。可能是上面朋友说的那样吧,我建的不是AJAX的项目哎