⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 default.aspx

📁 C# net Ajax无刷新留言版源码直接解压即可使用
💻 ASPX
字号:
<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>ASP.NET 2.0 页面提交无刷新演示</title>
    <script type="text/javascript"> 
       function CallServer1(inputcontrol, context)
       { 
            context.innerHTML = "<IMG SRC='images/pie.gif' />Loading...";
            arg = 'ServerMethod1|' + inputcontrol.value;
            <%= ClientScript.GetCallbackEventReference(this, "arg", "ReceiveServerData1", "context")%>; 
        }
        
        function ReceiveServerData1(result, context) 
        {
            context.innerHTML = context.id + ":" + result;
        }
        
        function CallServer2(obj)
        {
            context = gridspan;
            context.innerHTML = "<IMG SRC='images/pie.gif' />数据加载中...";
            arg = "ServerMethod2|" + obj.value;
            <%= ClientScript.GetCallbackEventReference(this, "arg", "ReceiveServerData2", "context")%>;
        }
        
        function ReceiveServerData2(result, context)
        {
            context.innerHTML = result;
        }
        
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h1>Demo1:html按钮提交数据</h1><br />
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <input id="Button1" type="button" value="提交到Label1" onclick="CallServer1(TextBox1, Label1)"/>&nbsp;
        <input id="Button2" type="button" value="提交到Label2" onclick="CallServer1(TextBox1, Label2)"/>
        <br />
        <asp:Label ID="Label1" runat="server" Text="Label1:"></asp:Label>
        <br />
        <asp:Label ID="Label2" runat="server" Text="Label2:"></asp:Label>
    </div>
    <hr />
    <div>
        <h1>Demo2:服务器按钮提交数据</h1><br />
        <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
        <asp:Button ID="Button3" runat="server" Text="Button" /><br />
        <asp:Label ID="Label3" runat="server" Text="Label3:"></asp:Label></div>    
    <hr />
    <div>
        <h1>Demo3:下拉列表框和gridview绑定数据</h1><br />
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ connectionStrings:NorthWind %>"
            SelectCommand="select distinct(country) from customers"></asp:SqlDataSource>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ connectionStrings:NorthWind %>"
            SelectCommand="select customerid, companyname, country from customers where country=@Country">
            <SelectParameters>
                <asp:ControlParameter Name="Country" ControlID="DropDownList1" PropertyName="SelectedValue" />
            </SelectParameters>
        </asp:SqlDataSource>
        <div>
            <asp:DropDownList ID="DropDownList1" runat="server" Width="239px" 
                DataSourceID="SqlDataSource1" DataTextField="Country" DataValueField="Country">
            </asp:DropDownList>
        </div>
        <br />
        <span id="gridspan">
            <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource2">
            </asp:GridView>
        </span>
    </div>
    </form>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -