并且在UpdatePanel中弹出对话框。
熟悉控件的使用方法,因此没有考虑性能以及代码的规范等问题!
首先的先安装 ASP.NET AJAX框架。( 官方下载地址)。本文的实例 源程序下载地址。
安装完成后,Microsoft Visual Studio 2005中工具栏会有如下控件
部分代码:
首先需要在页面中加入ScriptManager控件,每个页面只能有一个ScriptManager控件。
<
asp:ScriptManager
ID
="ScriptManager1"
runat
="server"
></
asp:ScriptManager
>
然后加入
<
asp:UpdatePanel
ID
="uid"
runat
="server"
>
< ContentTemplate >
< asp:Button ID ="Button1" runat ="server" Text ="异步回送得到数据" OnClick ="Button1_Click" />
< asp:Button ID ="Button2" runat ="server" Text ="整页回送 --刷新页面" OnClick ="Button2_Click" />< br />
< asp:GridView ID ="GridView1" runat ="server" AutoGenerateColumns ="False" Width ="100%" DataKeyNames ="userid" OnRowCancelingEdit ="GridView1_RowCancelingEdit" OnRowDeleting ="GridView1_RowDeleting" OnRowEditing ="GridView1_RowEditing" OnRowUpdating ="GridView1_RowUpdating" >
< Columns >
< asp:BoundField DataField ="userid" HeaderText ="userid" />
< asp:BoundField DataField ="username" HeaderText ="username" />
< asp:CommandField ShowEditButton ="True" />
< asp:CommandField ShowDeleteButton ="True" />
</ Columns >
</ asp:GridView >
< br />
< asp:Label ID ="Label1" runat ="server" Font-Bold ="True" Font-Size ="Large" Width ="239px" ></ asp:Label >
</ div >
</ ContentTemplate >
< Triggers >
< asp:AsyncPostBackTrigger ControlID ="Button1" /> <% -- 注册控件的调用方法-- %>
< asp:AsyncPostBackTrigger ControlID ="Button3" /> <% --这两个控件无刷新调用 -- %>
< asp:PostBackTrigger ControlID ="Button2" />
</ Triggers >
</ asp:UpdatePanel >
< ContentTemplate >
< asp:Button ID ="Button1" runat ="server" Text ="异步回送得到数据" OnClick ="Button1_Click" />
< asp:Button ID ="Button2" runat ="server" Text ="整页回送 --刷新页面" OnClick ="Button2_Click" />< br />
< asp:GridView ID ="GridView1" runat ="server" AutoGenerateColumns ="False" Width ="100%" DataKeyNames ="userid" OnRowCancelingEdit ="GridView1_RowCancelingEdit" OnRowDeleting ="GridView1_RowDeleting" OnRowEditing ="GridView1_RowEditing" OnRowUpdating ="GridView1_RowUpdating" >
< Columns >
< asp:BoundField DataField ="userid" HeaderText ="userid" />
< asp:BoundField DataField ="username" HeaderText ="username" />
< asp:CommandField ShowEditButton ="True" />
< asp:CommandField ShowDeleteButton ="True" />
</ Columns >
</ asp:GridView >
< br />
< asp:Label ID ="Label1" runat ="server" Font-Bold ="True" Font-Size ="Large" Width ="239px" ></ asp:Label >
</ div >
</ ContentTemplate >
< Triggers >
< asp:AsyncPostBackTrigger ControlID ="Button1" /> <% -- 注册控件的调用方法-- %>
< asp:AsyncPostBackTrigger ControlID ="Button3" /> <% --这两个控件无刷新调用 -- %>
< asp:PostBackTrigger ControlID ="Button2" />
</ Triggers >
</ asp:UpdatePanel >
这样,不用在编写任何代码,就可以实现不刷新的效果!
以上是部分代码, 源程序下载地址。
声明:熟悉控件的使用方法,因此没有考虑性能以及代码的规范等问题!