日期:2014-05-16 浏览次数:20429 次
<%@ 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></title> <script src="js/jquery-1.4.2.min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function() { $("#Button1").click(function() { //按钮点击事件 Sel($("#TextBox1").val()); //执行Sel方法,并把文本框值传过去 }); }); function Sel(values) { $.get("Default.aspx", { v: values }, function(dt) { alert(dt);//弹出查询结果 }); } </script> </head> <body> <form id="form1" runat="server"> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:Button ID="Button1" runat="server" Text="Button" /> </form> </body> </html>
protected void Page_Load(object sender, EventArgs e) { var v = Request["v"]; //获取参数,也就是文本框的值 if (!string.IsNullOrEmpty(v)) //判断是否为空 { Response.Clear(); if (v == "v") //v==v,是为了模拟查询数据库的返回结果 { var data = "[[\"1\",\"600000\",\"600000\",\"浦发银行\"],[\"2\",\"600001\",\"600001\",\"邯郸钢铁\"],[\"3\",\"600002\",\"600002\",\"齐鲁石化\"]]"; Response.Write(data); Response.Flush(); Response.End(); } } }
protected void Page_Load(object sender, EventArgs e) { var v = Request["v"]; //获取参数,也就是文本框的值 string type = Request.QueryString["type"]; if(type=='ajax'){ if (!string.IsNullOrEmpty(v)) //判断是否为空 { Response.Clear(); if (v == "v") //v==v,是为了模拟查询数据库的返回结果 { var data = "[[\"1\",\"600000\",\"600000\",\"浦发银行\"],[\"2\",\"600001\",\"600001\",\"邯郸钢铁\"],[\"3\",\"600002\",\"600002\",\"齐鲁石化\"]]"; Response.Write(data); Response.Flush(); Response.End(); } }else{ Response.End(); } } }