$.ajax返回的页面取里面控件的值

前端之家收集整理的这篇文章主要介绍了$.ajax返回的页面取里面控件的值前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

A.aspx页面前端脚本

jQuery.ajax({

url: "Search.aspx",
data: "UserId=" + info,
cache: false,
success: function (html) {
var t = (jQuery("#lblshow"),(jQuery(html))).text();//获取返回页面控件span 的id 为lblshow的内容
if (t == "") {
jQuery("#ddBank").dialog('close');


} else {
//alert(t);
var gsdm = '';
if (jQuery("#sddlCompanyName").val().indexOf('请选择') > -1)
{ }
else {
gsdm = jQuery("#sddlCompanyName").val();
}
SeachBankCode(t,'',gsdm);
}
}

});


Search.aspx页面

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Search.aspx.cs" Inherits="Sheets_Search" %>


<!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>
<asp:Label ID="lblshow" runat="server" Text=""></asp:Label>
</body>
</html>


Search.aspx后台代码

using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Maticsoft.DBUtility; public partial class Sheets_Search : System.Web.UI.Page { protected void Page_Load(object sender,EventArgs e) { if (!IsPostBack) { this.lblshow.Text = ""; string sntext = Request.QueryString["UserId"].ToString().Trim(); if (sntext == "" || sntext == null) { this.lblshow.Text = ""; } else { if (DbHelpersql.Query("select * from ot_user where ObjectID='"+sntext+"'").Tables[0].Rows.Count > 0) { this.lblshow.Text = DbHelpersql.Query("select * from ot_user where ObjectID='" + sntext + "'").Tables[0].Rows[0]["EmployeeNumber"].ToString().Trim(); } else { this.lblshow.Text = ""; } } } } }

猜你在找的Ajax相关文章