您的位置:首页 > 其它

Ajax基础应用入门01

2012-03-26 10:14 441 查看
1、新建一个“Asp.NET 空应用程序”,并添加一个web窗体;

2、在web窗体前台页面中添加两个div(以查询的方式验证ajax的效果);

(1).在第一个div中拖入一个label控件,将其属性名称改为“ID”;一个textbox控件“txtStudentID” ;一个按钮,属性名:查询;

(2).在第二个div中拖入两个label控件,第一个属性名改为学生姓名,第二个用于显示查询结果,ID改为lblStudentName;

3、双击“查询”按钮进入后台添加后台代码:

View Code

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApp_ajax.WebForm1" %>

<!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></title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager><%--它用来处理页面上的所有组件以及页面局部更新,生成相关的客户端代理脚本以便能够在JavaScript中访问Web Service,
所有需要支持ASP.NET AJAX的ASP.NET页面上有且只能有一个ScriptManager控件。在ScriptManager控件中我们可以指定需要的脚本库,
或者指定通过JS来调用的Web Service,以及调用AuthenticationService和ProfileService,还有页面错误处理等。[ɔ:,θenti'keiʃən]验证--%>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div>
<asp:Label ID="Label1" runat="server" Text="学生ID:"></asp:Label>
<asp:TextBox ID="txtDemand" runat="server"></asp:TextBox>
<asp:Button ID="btnDemand" runat="server" Text="查询" OnClick="btnDemand_Click" />
</div>
<div>
<asp:Label ID="Label2" runat="server" Text="学生姓名:"></asp:Label>
 <asp:Label ID="lblStudentName" runat="server" Text="Label"></asp:Label>
</div>

</ContentTemplate>
</asp:UpdatePanel>
<iframe src="http://www.baidu.com" width="1000" height="400"></iframe>
</form>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: