我在vs2008建立ajax网站,发现不起作用
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <div>
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                    <asp:Button ID="Button1" runat="server" Text="Button" />
                    <%DateTime.Now.ToString(); %>
                </ContentTemplate>
            </asp:UpdatePanel>
        </div>
    </form>
</body>
</html>点击按钮时确实不刷新了,但是也不显示内容了,谢谢了。

解决方案 »

  1.   

     <%DateTime.Now.ToString(); %>
     你这里能显示嘛?
      

  2.   

      <%response.write(DateTime.Now.ToString());%>
      

  3.   

    <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional" >
      <ContentTemplate>
      <%= DateTime.Now.ToString()%>
      <asp:Button ID="Button2" runat="server" Text="Button" />
      </ContentTemplate>
      </asp:UpdatePanel>
      

  4.   

    <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional" >
      <ContentTemplate>
      <%= DateTime.Now.ToString()%>
      <asp:Button ID="Button2" runat="server" Text="Button" />
      </ContentTemplate>
      </asp:UpdatePanel><asp:ScriptManager ID="ScriptManager1" runat="server">
      </asp:ScriptManager>
      <asp:Timer ID="Timer1" runat="server" Interval="1000" ontick="Timer1_Tick">
      </asp:Timer>
      <asp:UpdatePanel ID="UpdatePanel1" runat="server">
      <ContentTemplate>当前时间是:
      <asp:Label ID="Lbtime" runat="server" Text="Label"></asp:Label>
      </ContentTemplate>
      </asp:UpdatePanel>
    后台cs:
    protected void Timer1_Tick(object sender, EventArgs e)
      {
      this.Lbtime.Text = DateTime.Now.ToString();
      }