2<head runat="server">
3 <title>无标题页</title>
4 <script type="text/javascript">
5
6 function pageLoad() {
7 }
8
9 </script>
10</head>
11<body>
12 <form id="form1" runat="server">
13 <div>
14 <asp:ScriptManager ID="ScriptManager1" runat="server" />
15 </div>
16 <asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="False"
17 UpdateMode="Conditional">
18 <ContentTemplate>
19 联系方式为:<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
20 <asp:Button ID="Button1" runat="server" Font-Bold="True" Font-Size="Medium"
21 Height="26px" Text="…" />
22 <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
23 <ContentTemplate>
24 <asp:GridView ID="GridView1" runat="server" AllowPaging="True"
25 AutoGenerateColumns="False" BackColor="White" BorderColor="White"
26 BorderStyle="Ridge" BorderWidth="2px" CellPadding="3" CellSpacing="1"
27 DataKeyNames="ID" DataSourceID="SqlDataSource1" EmptyDataText="没有可显示的数据记录。"
28 GridLines="None">
29 <FooterStyle BackColor="#C6C3C6" ForeColor="Black" />
30 <RowStyle BackColor="#DEDFDE" ForeColor="Black" />
31 <Columns>
32 <asp:CommandField ShowSelectButton="True" />
33 <asp:BoundField DataField="type" HeaderText="type" SortExpression="type" />
34 <asp:BoundField DataField="title" HeaderText="title" SortExpression="title" />
35 <asp:BoundField DataField="info" HeaderText="info" SortExpression="info" />
36 <asp:BoundField DataField="linkman" HeaderText="linkman"
37 SortExpression="linkman" />
38 <asp:BoundField DataField="tel" HeaderText="tel" SortExpression="tel" />
39 <asp:CheckBoxField DataField="checkState" HeaderText="checkState"
40 SortExpression="checkState" />
41 <asp:BoundField DataField="date" HeaderText="date" SortExpression="date" />
42 </Columns>
43 <PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Right" />
44 <SelectedRowStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" />
45 <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#E7E7FF" />
46 </asp:GridView>
47 <asp:SqlDataSource ID="SqlDataSource1" runat="server"
48 ConnectionString="<%$ ConnectionStrings:db_SISConnectionString1 %>"
49 DeleteCommand="DELETE FROM [tb_info] WHERE [ID] = @ID"
50 InsertCommand="INSERT INTO [tb_info] ([type], [title], [info], [linkman], [tel], [checkState], [date]) VALUES (@type, @title, @info, @linkman, @tel, @checkState, @date)"
51 ProviderName="<%$ ConnectionStrings:db_SISConnectionString1.ProviderName %>"
52 SelectCommand="SELECT [ID], [type], [title], [info], [linkman], [tel], [checkState], [date] FROM [tb_info]"
53 UpdateCommand="UPDATE [tb_info] SET [type] = @type, [title] = @title, [info] = @info, [linkman] = @linkman, [tel] = @tel, [checkState] = @checkState, [date] = @date WHERE [ID] = @ID">
54 <DeleteParameters>
55 <asp:Parameter Name="ID" Type="Int32" />
56 </DeleteParameters>
57 <InsertParameters>
58 <asp:Parameter Name="type" Type="String" />
59 <asp:Parameter Name="title" Type="String" />
60 <asp:Parameter Name="info" Type="String" />
61 <asp:Parameter Name="linkman" Type="String" />
62 <asp:Parameter Name="tel" Type="String" />
63 <asp:Parameter Name="checkState" Type="Boolean" />
64 <asp:Parameter Name="date" Type="DateTime" />
65 </InsertParameters>
66 <UpdateParameters>
67 <asp:Parameter Name="type" Type="String" />
68 <asp:Parameter Name="title" Type="String" />
69 <asp:Parameter Name="info" Type="String" />
70 <asp:Parameter Name="linkman" Type="String" />
71 <asp:Parameter Name="tel" Type="String" />
72 <asp:Parameter Name="checkState" Type="Boolean" />
73 <asp:Parameter Name="date" Type="DateTime" />
74 <asp:Parameter Name="ID" Type="Int32" />
75 </UpdateParameters>
76 </asp:SqlDataSource>
77 </ContentTemplate>
78 <Triggers>
79 <asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
80 </Triggers>
81 </asp:UpdatePanel>
82 </ContentTemplate>
83 <Triggers>
84 <asp:AsyncPostBackTrigger ControlID="GridView1"
85 EventName="SelectedIndexChanged" />
86 </Triggers>
87 </asp:UpdatePanel>
88 <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
89 <ProgressTemplate>
90 <asp:Label ID="Label1" runat="server" Text="请等待,勿操作" Width="150px"></asp:Label>
91 <input ID="Button2" type="button" value="取消当前操作" />
92 </ProgressTemplate>
93 </asp:UpdateProgress>
94 </form>
95</body>
96</html>
2using System.Web.UI.WebControls.WebParts;
3using System.Xml.Linq;
4
5public partial class UpdateProgress : System.Web.UI.Page
6{
7 protected void Page_Load(object sender, EventArgs e)
8 {
9 if(!this .IsPostBack)
10 GridView1.Visible = false;
11 }
12 //当点击Button1时GridView显示出来,如果已经显示就隐藏
13 protected void Button1_Click(object sender, EventArgs e)
14 {
15 if (!GridView1.Visible)
16 GridView1.Visible = true;
17 else
18 GridView1.Visible = false;
19 }
20 //当GridView选中行时,textbox的值为选中行的第6个单元格的值,然后GridView再次隐藏
21 protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
22 {
23 TextBox1.Text = GridView1.SelectedRow.Cells[5].Text.ToString();
24 GridView1.Visible = false;
25 }
26}
2 protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
3 { //选中后等待10秒,10秒后再获取值
4 System.Threading.Thread.Sleep(10000);
5 TextBox1.Text = GridView1.SelectedRow.Cells[5].Text.ToString();
6 GridView1.Visible = false;
7 }
2
3<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4
5<html xmlns="http://www.w3.org/1999/xhtml">
6<head runat="server">
7 <title>无标题页</title>
8 <script type="text/javascript">
9
10 function pageLoad() {
11 }
12
13 </script>
14</head>
15<body>
16 <form id="form1" runat="server">
17 <div>
18 <asp:ScriptManager ID="ScriptManager1" runat="server" />
19 <script language ="javascript" >
20 //取得PageRequestManager对象,每一个Asp.net Ajax页面中会右唯一一个这种对象负责处理所有的Async-Postback要求
21 var prm=Sys .WebForms .PageRequestManager.getInstance();
22 //新增事件处理至PageRequestManager的initializeRequest事件,当Async-Postback发生时,此事件会被触发,我们的InitRequest函数便会被运行
23 prm.add_initializeRequest(InitRequest);
24 //新增事件处理至PageRequestManager的endRequest事件,当Async-Postback完成时,此事件会被触发,我们的EndRequest函数便会被运行
25 prm.add_endRequest(EndRequest);
26 function InitRequest(sender,args)
27 {
28 //显示出UpdateProgress1控件
29 document .getElementById ("UpdateProgress1").style.display="block";
30 }
31 function EndRequest(sender,args)
32 {
33 //隐藏UpdateProgress1控件
34 document .getElementById ("UpdateProgress1").style.display="none";
35 }
36 //用于取消Async-Postback动作
37 function CancelClick()
38 {
39 //当处于Async-Postback动作时,get_isInAsyncPostBack函数会回传true,此时调用abortPostBack 函数便会取消Async-Postback动作。
40 if(prm.get_isInAsyncPostBack())
41 {
42 prm.abortPostBack ();
43 }
44
45 }
46
47 </script>
48 </div>
49 <asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="False"
50 UpdateMode="Conditional">
51 <ContentTemplate>
52 联系方式为:<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
53 <asp:Button ID="Button1" runat="server" Font-Bold="True" Font-Size="Medium"
54 Height="26px" Text="…" />
55 <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
56 <ContentTemplate>
57 <asp:GridView ID="GridView1" runat="server" AllowPaging="True"
58 AutoGenerateColumns="False" BackColor="White" BorderColor="White"
59 BorderStyle="Ridge" BorderWidth="2px" CellPadding="3" CellSpacing="1"
60 DataKeyNames="ID" DataSourceID="SqlDataSource1" EmptyDataText="没有可显示的数据记录。"
61 GridLines="None" onselectedindexchanged="GridView1_SelectedIndexChanged">
62 <FooterStyle BackColor="#C6C3C6" ForeColor="Black" />
63 <RowStyle BackColor="#DEDFDE" ForeColor="Black" />
64 <Columns>
65 <asp:CommandField ShowSelectButton="True" />
66 <asp:BoundField DataField="type" HeaderText="type" SortExpression="type" />
67 <asp:BoundField DataField="title" HeaderText="title" SortExpression="title" />
68 <asp:BoundField DataField="info" HeaderText="info" SortExpression="info" />
69 <asp:BoundField DataField="linkman" HeaderText="linkman"
70 SortExpression="linkman" />
71 <asp:BoundField DataField="tel" HeaderText="tel" SortExpression="tel" />
72 <asp:CheckBoxField DataField="checkState" HeaderText="checkState"
73 SortExpression="checkState" />
74 <asp:BoundField DataField="date" HeaderText="date" SortExpression="date" />
75 </Columns>
76 <PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Right" />
77 <SelectedRowStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" />
78 <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#E7E7FF" />
79 </asp:GridView>
80 <asp:SqlDataSource ID="SqlDataSource1" runat="server"
81 ConnectionString="<%$ ConnectionStrings:db_SISConnectionString1 %>"
82 DeleteCommand="DELETE FROM [tb_info] WHERE [ID] = @ID"
83 InsertCommand="INSERT INTO [tb_info] ([type], [title], [info], [linkman], [tel], [checkState], [date]) VALUES (@type, @title, @info, @linkman, @tel, @checkState, @date)"
84 ProviderName="<%$ ConnectionStrings:db_SISConnectionString1.ProviderName %>"
85 SelectCommand="SELECT [ID], [type], [title], [info], [linkman], [tel], [checkState], [date] FROM [tb_info]"
86 UpdateCommand="UPDATE [tb_info] SET [type] = @type, [title] = @title, [info] = @info, [linkman] = @linkman, [tel] = @tel, [checkState] = @checkState, [date] = @date WHERE [ID] = @ID">
87 <DeleteParameters>
88 <asp:Parameter Name="ID" Type="Int32" />
89 </DeleteParameters>
90 <InsertParameters>
91 <asp:Parameter Name="type" Type="String" />
92 <asp:Parameter Name="title" Type="String" />
93 <asp:Parameter Name="info" Type="String" />
94 <asp:Parameter Name="linkman" Type="String" />
95 <asp:Parameter Name="tel" Type="String" />
96 <asp:Parameter Name="checkState" Type="Boolean" />
97 <asp:Parameter Name="date" Type="DateTime" />
98 </InsertParameters>
99 <UpdateParameters>
100 <asp:Parameter Name="type" Type="String" />
101 <asp:Parameter Name="title" Type="String" />
102 <asp:Parameter Name="info" Type="String" />
103 <asp:Parameter Name="linkman" Type="String" />
104 <asp:Parameter Name="tel" Type="String" />
105 <asp:Parameter Name="checkState" Type="Boolean" />
106 <asp:Parameter Name="date" Type="DateTime" />
107 <asp:Parameter Name="ID" Type="Int32" />
108 </UpdateParameters>
109 </asp:SqlDataSource>
110 </ContentTemplate>
111 <Triggers>
112 <asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
113 </Triggers>
114 </asp:UpdatePanel>
115 </ContentTemplate>
116 <Triggers>
117 <asp:AsyncPostBackTrigger ControlID="GridView1"
118 EventName="SelectedIndexChanged" />
119 </Triggers>
120 </asp:UpdatePanel>
121 <asp:UpdateProgress ID="UpdateProgress1" runat="server"
122 AssociatedUpdatePanelID="UpdatePanel1">
123 <ProgressTemplate>
124 <asp:Label ID="Label1" runat="server" Text="请等待,勿操作" Width="150px"></asp:Label>
125 <input ID="Button2" type="button" value="取消当前操作" onclick="CancelClick()" />
126 </ProgressTemplate>
127 </asp:UpdateProgress>
128 </form>
129</body>
130</html>