前台页面:

使用几个display=none的空间存储DropdownList中的值,点击Search Button后刷新页面再次给DropdownList赋值使用

<%@ Page Language="c#" CodeBehind="MallListCAM.aspx.cs" AutoEventWireup="True" Inherits="PRCSales_internal.Mall.MallListCAM"
EnableEventValidation="false" %> <%@ Implements Interface="Idunno.AntiCsrf.ISuppressCsrfCheck" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
<title>MallList</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<link href="../css/Styles_1.css" type="text/css" rel="stylesheet">
<script language="javascript" src="../js/jquery-1.8.2.js"></script>
<script language="javascript" src="../js/locationFilter.js"></script>
<script language="javascript">
function Popup(url, width, height) {
var left = (window.screen.width - width) / 2;
var top = (window.screen.height - height) / 2;
window.open(url, '_blank', 'top=' + top + ',left=' + left + ',resizable=no,toolbar=no,width=' + width + ',height=' + height);
//window.open(url,'_blank','top=190,left=170,resizable=no,toolbar=no,width='+width+',height='+height);
//window.showModalDialog(url,window,'status=0;dialogWidth='+width+'px;dialogHeight='+height+'px;');
} function Refresh() {
document.Form1.btnSubmit.click();
} function Remove() { if (confirm("Are you sure to remove selected Mall?")) {
return true;
}
else {
return false;
} } </script>
</head>
<body ms_positioning="GridLayout">
<form id="Form1" method="post" runat="server">
<table cellspacing="0" cellpadding="0" width="100%">
<tr>
<td class="pagetitle">
<asp:Label ID="lblTitle" Style="z-index: 101; position: relative" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
<table width="100%">
<tr>
<td class="fieldtitle" width="50%" colspan="2">
Mall information
</td>
<td class="fieldtitle" width="50%" colspan="2">
<font color="#993333">
<asp:Label ID="lblComplete" runat="server"></asp:Label></font>
</td>
</tr>
<tr style="height: 1px; background-color: #3366ff">
<td colspan="4">
</td>
</tr>
<tr>
<td class="fieldtitle" width="50%" colspan="2">
Mall search
</td>
<td align="right" width="50%" colspan="2">
<asp:Button ID="btnSubmit" runat="server" Text="Search" CssClass="fieldButton" OnClick="btnSubmit_Click">
</asp:Button>
</td>
</tr>
<tr>
<td class="fieldtitle" width="20%">
Region/SubRegion/Grid/Prefecture/City/County/Town/Village:
</td>
<td class="fieldtitle" colspan="3">
<asp:DropDownList ID="ddlRegion" runat="server" CssClass="fieldList" onchange="initData('subregion')">
</asp:DropDownList>
<asp:DropDownList ID="ddlSubRegion" runat="server" CssClass="fieldList" onchange="initData('grid')">
</asp:DropDownList>
<asp:DropDownList ID="ddlGrid" runat="server" CssClass="fieldList" onchange="initData('pref')">
</asp:DropDownList>
<asp:DropDownList ID="ddlPref" runat="server" CssClass="fieldList" onchange="initData('city')">
</asp:DropDownList>
<asp:DropDownList ID="ddlCity" runat="server" CssClass="fieldList" onchange="initData('county')">
</asp:DropDownList>
<asp:DropDownList ID="ddlCounty" runat="server" CssClass="fieldList" onchange="initData('town')">
</asp:DropDownList>
<asp:DropDownList ID="ddlTown" runat="server" CssClass="fieldList" onchange="initData('village')">
</asp:DropDownList>
<asp:DropDownList ID="ddlVillage" runat="server" CssClass="fieldList">
</asp:DropDownList>
</td>
<td>
<asp:TextBox ID="txtWWID" runat="server" Style="display: none"></asp:TextBox>
<asp:TextBox ID="txtRegion" runat="server" Style="display: none"></asp:TextBox>
<asp:TextBox ID="txtSubRegion" runat="server" Style="display: none"></asp:TextBox>
<asp:TextBox ID="txtGrid" runat="server" Style="display: none"></asp:TextBox>
<asp:TextBox ID="txtPref" runat="server" Style="display: none"></asp:TextBox>
<asp:TextBox ID="txtCity" runat="server" Style="display: none"></asp:TextBox>
<asp:TextBox ID="txtCounty" runat="server" Style="display: none"></asp:TextBox>
<asp:TextBox ID="txtTown" runat="server" Style="display: none"></asp:TextBox>
<asp:TextBox ID="txtVillage" runat="server" Style="display: none"></asp:TextBox>
</td>
</tr>
<tr>
<td class="fieldtitle" width="25%">
Type:
</td>
<td class="fieldtitle" width="25%">
<asp:DropDownList ID="dplType" runat="server" CssClass="fieldList" AutoPostBack="True"
OnSelectedIndexChanged="dplType_SelectedIndexChanged">
</asp:DropDownList>
</td>
<td class="fieldtitle" width="25%">
Branding:
</td>
<td class="fieldtitle" width="25%">
<asp:DropDownList ID="dplBrd" runat="server" CssClass="fieldList">
</asp:DropDownList>
</td>
</tr>
<tr style="height: 1px; background-color: #3366ff">
<td colspan="4">
</td>
</tr>
<tr>
<td class="fieldtitle" width="25%">
Mall list&nbsp;&nbsp;&nbsp;&nbsp;<asp:Label ID="lblCount" runat="server" CssClass="fieldList"></asp:Label>
</td>
<td align="right" colspan="3">
<asp:Button ID="btnAdd" runat="server" CssClass="fieldButton" Text="Add" Width="60px">
</asp:Button>&nbsp;&nbsp;&nbsp;&nbsp;<asp:Button ID="btnExport" runat="server" Visible="False"
Text="Export" CssClass="fieldButton" Width="60px" OnClick="btnExport_Click">
</asp:Button>
</td>
</tr>
<tr>
<td colspan="4">
<asp:DataGrid ID="dg" Style="z-index: 101; position: relative" runat="server" Width="96%"
AutoGenerateColumns="False" PageSize="60" AllowPaging="True" AllowSorting="True">
<AlternatingItemStyle CssClass="datagridAlternating"></AlternatingItemStyle>
<HeaderStyle CssClass="tableHead"></HeaderStyle>
<Columns>
<asp:BoundColumn Visible="False" DataField="mall_id"></asp:BoundColumn>
<asp:BoundColumn DataField="grid_cd" HeaderText="Grid" SortExpression="grid_cd">
<ItemStyle HorizontalAlign="Center" Width="5%"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="pref_nm" HeaderText="Prefecture" SortExpression="pref_nm">
<ItemStyle HorizontalAlign="Center" Width="7%"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="city_std_loc_nm" HeaderText="City" SortExpression="city_std_loc_nm">
<ItemStyle HorizontalAlign="Center" Width="7%"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="county_nm" HeaderText="County Name" SortExpression="county_nm">
<ItemStyle HorizontalAlign="Center" Width="7%"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="town_nm" HeaderText="Town Name" SortExpression="town_nm">
<ItemStyle HorizontalAlign="Center" Width="7%"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="village_nm" HeaderText="Village Name" SortExpression="village_nm">
<ItemStyle HorizontalAlign="Center" Width="7%"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="mall_type_nm" HeaderText="Mall Type" SortExpression="mall_type_nm">
<ItemStyle HorizontalAlign="Center" Width="5%"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="mall_brnd_nm" HeaderText="Mall Branding" SortExpression="mall_brnd_nm">
<ItemStyle HorizontalAlign="Center" Width="5%"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="mall_nm" HeaderText="Mall Name" SortExpression="mall_nm">
<ItemStyle HorizontalAlign="Left" Width="23%"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="mall_addr" HeaderText="Address" SortExpression="mall_addr">
<ItemStyle HorizontalAlign="Left" Width="23%"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="last_upd_dtm" HeaderText="Last Updated at" DataFormatString="{0:M/d/yyyy}"
SortExpression="last_upd_dtm">
<ItemStyle HorizontalAlign="Center" Width="10%"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="last_upd_usr_nm" HeaderText="Last Updated by" SortExpression="last_upd_usr_nm">
<ItemStyle HorizontalAlign="Center" Width="5%"></ItemStyle>
</asp:BoundColumn>
<asp:TemplateColumn HeaderText="Action">
<ItemStyle HorizontalAlign="Center" Width="5%"></ItemStyle>
<ItemTemplate>
<a href="javascript:Popup('MallProfile.aspx?action=edit&mall_id=<%# DataBinder.Eval(Container, "DataItem.mall_id") %>','850','600');void(0);">
Edit</a>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="">
<ItemStyle HorizontalAlign="Center" Width="5%"></ItemStyle>
<ItemTemplate>
<asp:LinkButton ID="btn_Delete" CssClass="Command" Text='Delete' CommandName="delete"
CommandArgument='<%# DataBinder.Eval(Container.DataItem, "mall_id") %>' runat="server">
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
<PagerStyle Position="TopAndBottom" Mode="NumericPages"></PagerStyle>
</asp:DataGrid>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>

JS代码:

注意在Ajax中调用ashx页面中的function的方式。

$(document).ready(function () {
var Rgn_cd = "";
var Subrgn_cd = "";
var Grid_cd = "";
var Pref_cd = "";
var City_id = "";
var County_id = "";
var Town_id = "";
var Village_id = "";
var Type = "region";
var WWID = $("#txtWWID").val(); $.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
dataType: "json",
url: "../LocationFilter.ashx",
data: "{rgn_cd:'" + Rgn_cd + "', subrgn_cd:'" + Subrgn_cd + "',grid_cd:'" + Grid_cd + "',pref_cd:'" + Pref_cd + "',city_id:'" + City_id + "',county_id:'" + County_id + "',town_id:'" + Town_id + "',village_id:'" + Village_id + "',type:'" + Type + "',WWID:'" + WWID + "'}",
success: function (data) {
$("#ddlRegion").append($("<option value='ALL'>ALL</option>"));
$.each(data, function (i, item) {
$("#ddlRegion").append($("<option value='" + item.rgn_cd + "'>" + item.rgn_nm + "</option>"));
})
//alert($("#txtRegion").val());
$("#ddlRegion option[value='" + $("#txtRegion").val() + "']").attr("selected", true);
},
error: function (err) {
//alert("请等待Filter数据加载完毕再进行查询!");
}
}); updateData("subregion");
updateData("grid");
updateData("pref");
updateData("city");
updateData("county");
}) function initData(type) {
if (type == "subregion") {
clearData("subregion");
}
else if (type == "grid") {
clearData("grid");
}
else if (type == "pref") {
clearData("pref");
}
else if (type == "city") {
clearData("city");
}
else if (type == "county") {
clearData("county");
}
else if (type == "town") {
clearData("town");
} var Rgn_cd = $("#ddlRegion").val();
var Subrgn_cd = $("#ddlSubRegion").val();
var Grid_cd = $("#ddlGrid").val();
var Pref_cd = $("#ddlPref").val();
var City_id = $("#ddlCity").val();
var County_id = $("#ddlCounty").val();
var Town_id = $("#ddlTown").val();
var Village_id = $("#ddlVillage").val();
var Type = type;
var WWID = $("#txtWWID").val(); $.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
dataType: "json",
url: "../LocationFilter.ashx",
data: "{rgn_cd:'" + Rgn_cd + "', subrgn_cd:'" + Subrgn_cd + "',grid_cd:'" + Grid_cd + "',pref_cd:'" + Pref_cd + "',city_id:'" + City_id + "',county_id:'" + County_id + "',town_id:'" + Town_id + "',village_id:'" + Village_id + "',type:'" + Type + "',WWID:'" + WWID + "'}",
success: function (data) {
if (type == "subregion") {
$("#txtRegion").val(Rgn_cd);
updateData("grid");
updateData("pref");
updateData("city");
updateData("county");
$.each(data, function (i, item) {
$("#ddlSubRegion").append($("<option value='" + item.subrgn_cd + "'>" + item.subrgn_nm + "</option>"));
})
}
else if (type == "grid") {
$("#txtSubRegion").val(Subrgn_cd);
updateData("pref");
updateData("city");
updateData("county");
$.each(data, function (i, item) {
$("#ddlGrid").append($("<option value='" + item.grid_cd + "'>" + item.grid_nm + "</option>"));
})
}
else if (type == "pref") {
$("#txtGrid").val(Grid_cd);
updateData("city");
updateData("county");
$.each(data, function (i, item) {
$("#ddlPref").append($("<option value='" + item.pref_cd + "'>" + item.pref_nm + "</option>"));
})
}
else if (type == "city") {
$("#txtPref").val(Pref_cd);
updateData("county");
$.each(data, function (i, item) {
$("#ddlCity").append($("<option value='" + item.city_id + "'>" + item.name + "</option>"));
})
}
else if (type == "county") {
$("#txtCity").val(City_id);
updateData("town");
updateData("village");
$.each(data, function (i, item) {
$("#ddlCounty").append($("<option value='" + item.county_city_id + "'>" + item.county_name + "</option>"));
})
}
else if (type == "town") {
$("#txtCounty").val(County_id);
$.each(data, function (i, item) {
$("#ddlTown").append($("<option value='" + item.town_city_id + "'>" + item.town_name + "</option>"));
})
}
else if (type == "village") {
$("#txtTown").val(Town_id);
updateData("village");
$("#ddlVillage").empty();
$("#ddlVillage").append($("<option value='ALL'>ALL</option>"));
$.each(data, function (i, item) {
$("#ddlVillage").append($("<option value='" + item.village_city_id + "'>" + item.village_city_id + "</option>"));
})
}
},
error: function (err) {
//alert("err:" + err);
//alert("请等待Filter数据加载完毕再进行查询!");
}
});
} function updateData(type) {
if (type == "subregion") {
clearData("subregion");
}
else if (type == "grid") {
clearData("grid");
}
else if (type == "pref") {
clearData("pref");
}
else if (type == "city") {
clearData("city");
}
else if (type == "county") {
clearData("county");
}
else if (type == "town") {
clearData("town");
} var Rgn_cd = $("#ddlRegion").val();
var Subrgn_cd = $("#ddlSubRegion").val();
var Grid_cd = $("#ddlGrid").val();
var Pref_cd = $("#ddlPref").val();
var City_id = $("#ddlCity").val();
var County_id = $("#ddlCounty").val();
var Town_id = $("#ddlTown").val();
var Village_id = $("#ddlVillage").val();
var Type = type;
var WWID = $("#txtWWID").val(); if (type == "subregion" && $("#txtRegion").val() != "") {
Rgn_cd = $("#txtRegion").val();
}
if (type == "grid" && $("#txtSubRegion").val() != "") {
Subrgn_cd = $("#txtSubRegion").val();
}
if (type == "pref" && $("#txtGrid").val() != "") {
Grid_cd = $("#txtGrid").val();
}
if (type == "city" && $("#txtPref").val() != "") {
Pref_cd = $("#txtPref").val();
}
if (type == "county" && $("#txtCity").val() != "") {
City_id = $("#txtCity").val();
} $.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
dataType: "json",
url: "../LocationFilter.ashx",
data: "{rgn_cd:'" + Rgn_cd + "', subrgn_cd:'" + Subrgn_cd + "',grid_cd:'" + Grid_cd + "',pref_cd:'" + Pref_cd + "',city_id:'" + City_id + "',county_id:'" + County_id + "',town_id:'" + Town_id + "',village_id:'" + Village_id + "',type:'" + Type + "',WWID:'" + WWID + "'}",
success: function (data) {
if (type == "subregion") {
$.each(data, function (i, item) {
if (item.subrgn_cd == $("#txtSubRegion").val()) {
$("#ddlSubRegion").append($("<option value='" + item.subrgn_cd + "' selected = 'selected'>" + item.subrgn_nm + "</option>"));
}
else {
$("#ddlSubRegion").append($("<option value='" + item.subrgn_cd + "'>" + item.subrgn_nm + "</option>"));
}
//$("#ddlSubRegion").append($("<option value='" + item.subrgn_cd + "'>" + item.subrgn_nm + "</option>"));
})
}
else if (type == "grid") {
$.each(data, function (i, item) {
if (item.grid_cd == $("#txtGrid").val()) {
$("#ddlGrid").append($("<option value='" + item.grid_cd + "' selected = 'selected'>" + item.grid_nm + "</option>"));
}
else {
$("#ddlGrid").append($("<option value='" + item.grid_cd + "'>" + item.grid_nm + "</option>"));
}
//$("#ddlGrid").append($("<option value='" + item.grid_cd + "'>" + item.grid_nm + "</option>"));
})
}
else if (type == "pref") {
$.each(data, function (i, item) {
if (item.pref_cd == $("#txtPref").val()) {
$("#ddlPref").append($("<option value='" + item.pref_cd + "' selected = 'selected'>" + item.pref_nm + "</option>"));
}
else {
$("#ddlPref").append($("<option value='" + item.pref_cd + "'>" + item.pref_nm + "</option>"));
}
//$("#ddlPref").append($("<option value='" + item.pref_cd + "'>" + item.pref_nm + "</option>"));
})
}
else if (type == "city") {
$.each(data, function (i, item) {
if (item.city_id == $("#txtCity").val()) {
$("#ddlCity").append($("<option value='" + item.city_id + "' selected = 'selected'>" + item.name + "</option>"));
}
else {
$("#ddlCity").append($("<option value='" + item.city_id + "'>" + item.name + "</option>"));
}
//$("#ddlCity").append($("<option value='" + item.city_id + "'>" + item.name + "</option>"));
})
}
else if (type == "county") {
$.each(data, function (i, item) {
if (item.county_city_id == $("#txtCounty").val()) {
$("#ddlCounty").append($("<option value='" + item.county_city_id + "' selected = 'selected'>" + item.county_name + "</option>"));
}
else {
$("#ddlCounty").append($("<option value='" + item.county_city_id + "'>" + item.county_name + "</option>"));
}
//$("#ddlCounty").append($("<option value='" + item.county_city_id + "'>" + item.county_name + "</option>"));
})
}
else if (type == "town") {
$.each(data, function (i, item) {
if (item.town_city_id == $("#txtTown").val()) {
$("#ddlTown").append($("<option value='" + item.town_city_id + "' selected = 'selected'>" + item.town_name + "</option>"));
}
else {
$("#ddlTown").append($("<option value='" + item.town_city_id + "'>" + item.town_name + "</option>"));
}
//$("#ddlTown").append($("<option value='" + item.town_city_id + "'>" + item.town_name + "</option>"));
})
}
else if (type == "village") {
$("#ddlVillage").empty();
$("#ddlVillage").append($("<option value='ALL'>ALL</option>"));
$.each(data, function (i, item) {
if (item.village_city_id == $("#txtVillage").val()) {
$("#ddlVillage").append($("<option value='" + item.village_city_id + "' selected = 'selected'>" + item.village_city_id + "</option>"));
}
else {
$("#ddlVillage").append($("<option value='" + item.village_city_id + "'>" + item.village_city_id + "</option>"));
}
//$("#ddlVillage").append($("<option value='" + item.village_city_id + "'>" + item.village_city_id + "</option>"));
})
}
},
error: function (err) {
//alert("err:" + err);
//alert("请等待Filter数据加载完毕再进行查询!");
}
});
} function clearData(type) {
if (type == "subregion") {
$("#ddlSubRegion").empty();
$("#ddlSubRegion").append($("<option value='ALL'>ALL</option>"));
$("#ddlGrid").empty();
$("#ddlGrid").append($("<option value='ALL'>ALL</option>"));
$("#ddlPref").empty();
$("#ddlPref").append($("<option value='ALL'>ALL</option>"));
$("#ddlCity").empty();
$("#ddlCity").append($("<option value='ALL'>ALL</option>"));
$("#ddlCounty").empty();
$("#ddlCounty").append($("<option value='ALL'>ALL</option>"));
$("#ddlTown").empty();
$("#ddlTown").append($("<option value='ALL'>ALL</option>"));
$("#ddlVillage").empty();
$("#ddlVillage").append($("<option value='ALL'>ALL</option>"));
}
else if (type == "grid") {
$("#ddlGrid").empty();
$("#ddlGrid").append($("<option value='ALL'>ALL</option>"));
$("#ddlPref").empty();
$("#ddlPref").append($("<option value='ALL'>ALL</option>"));
$("#ddlCity").empty();
$("#ddlCity").append($("<option value='ALL'>ALL</option>"));
$("#ddlCounty").empty();
$("#ddlCounty").append($("<option value='ALL'>ALL</option>"));
$("#ddlTown").empty();
$("#ddlTown").append($("<option value='ALL'>ALL</option>"));
$("#ddlVillage").empty();
$("#ddlVillage").append($("<option value='ALL'>ALL</option>"));
}
else if (type == "pref") {
$("#ddlPref").empty();
$("#ddlPref").append($("<option value='ALL'>ALL</option>"));
$("#ddlCity").empty();
$("#ddlCity").append($("<option value='ALL'>ALL</option>"));
$("#ddlCounty").empty();
$("#ddlCounty").append($("<option value='ALL'>ALL</option>"));
$("#ddlTown").empty();
$("#ddlTown").append($("<option value='ALL'>ALL</option>"));
$("#ddlVillage").empty();
$("#ddlVillage").append($("<option value='ALL'>ALL</option>"));
}
else if (type == "city") {
$("#ddlCity").empty();
$("#ddlCity").append($("<option value='ALL'>ALL</option>"));
$("#ddlCounty").empty();
$("#ddlCounty").append($("<option value='ALL'>ALL</option>"));
$("#ddlTown").empty();
$("#ddlTown").append($("<option value='ALL'>ALL</option>"));
$("#ddlVillage").empty();
$("#ddlVillage").append($("<option value='ALL'>ALL</option>"));
}
else if (type == "county") {
$("#ddlCounty").empty();
$("#ddlCounty").append($("<option value='ALL'>ALL</option>"));
$("#ddlTown").empty();
$("#ddlTown").append($("<option value='ALL'>ALL</option>"));
$("#ddlVillage").empty();
$("#ddlVillage").append($("<option value='ALL'>ALL</option>"));
}
else if (type == "town") {
$("#ddlTown").empty();
$("#ddlTown").append($("<option value='ALL'>ALL</option>"));
$("#ddlVillage").empty();
$("#ddlVillage").append($("<option value='ALL'>ALL</option>"));
}
}

ashx页面代码:

由于前面JS中Get的为Json数据,在ProcessRequest中设置:context.Response.ContentType = "text/json";

using System;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using Intel.PRCSMS.Common; using Newtonsoft.Json;
using System.IO;
using System.Web.Script.Serialization;
using System.Collections.Generic; namespace PRCSales_internal
{
/// <summary>
/// Summary description for LocationFilter
/// </summary>
public class LocationFilter : IHttpHandler
{ public void ProcessRequest(HttpContext context)
{ HttpResponse res = context.Response;
res.ContentType = "text/json"; Dictionary<String, Object> dicParameter = GetParameter(context);
string rgn_cd = dicParameter["rgn_cd"].ToString();
string subrgn_cd = dicParameter["subrgn_cd"].ToString();
string grid_cd = dicParameter["grid_cd"].ToString();
string pref_cd = dicParameter["pref_cd"].ToString();
string city_id = dicParameter["city_id"].ToString();
string county_id = dicParameter["county_id"].ToString();
string town_id = dicParameter["town_id"].ToString();
string village_id = dicParameter["village_id"].ToString();
string type = dicParameter["type"].ToString();
string WWID = dicParameter["WWID"].ToString(); SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["DSN"].DecodeBase64()); SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "region_subregion_grid_pref_city_county_town_village_by_wwid";
cmd.Connection = conn; if (string.IsNullOrEmpty(rgn_cd) || rgn_cd == "null" || rgn_cd == "ALL")
{
cmd.Parameters.AddWithValue("@rgn_cd", DBNull.Value);
}
else
{
cmd.Parameters.AddWithValue("@rgn_cd", rgn_cd);
} if (string.IsNullOrEmpty(subrgn_cd) || subrgn_cd == "null" || subrgn_cd == "ALL")
{
cmd.Parameters.AddWithValue("@subrgn_cd", DBNull.Value);
}
else
{
cmd.Parameters.AddWithValue("@subrgn_cd", subrgn_cd);
} if (string.IsNullOrEmpty(grid_cd) || grid_cd == "null" || grid_cd == "ALL")
{
cmd.Parameters.AddWithValue("@grid_cd", DBNull.Value);
}
else
{
cmd.Parameters.AddWithValue("@grid_cd", grid_cd);
} if (string.IsNullOrEmpty(pref_cd) || pref_cd == "null" || pref_cd == "ALL")
{
cmd.Parameters.AddWithValue("@pref_cd", DBNull.Value);
}
else
{
cmd.Parameters.AddWithValue("@pref_cd", pref_cd);
} if (string.IsNullOrEmpty(city_id) || city_id == "null" || city_id == "ALL")
{
cmd.Parameters.AddWithValue("@city_id", DBNull.Value);
}
else
{
cmd.Parameters.AddWithValue("@city_id", city_id);
} if (string.IsNullOrEmpty(county_id) || county_id == "null" || county_id == "ALL")
{
cmd.Parameters.AddWithValue("@county_id", DBNull.Value);
}
else
{
cmd.Parameters.AddWithValue("@county_id", city_id);
} if (string.IsNullOrEmpty(town_id) || town_id == "null" || town_id == "ALL")
{
cmd.Parameters.AddWithValue("@town_id", DBNull.Value);
}
else
{
cmd.Parameters.AddWithValue("@town_id", town_id);
} if (string.IsNullOrEmpty(village_id) || village_id == "null" || village_id == "ALL")
{
cmd.Parameters.AddWithValue("@village_id", DBNull.Value);
}
else
{
cmd.Parameters.AddWithValue("@village_id", village_id);
}
cmd.Parameters.AddWithValue("@type", type);
cmd.Parameters.AddWithValue("@wwid", "");// WWID SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd; DataTable dt = new DataTable(); conn.Open();
da.Fill(dt); conn.Close();
da.Dispose();
cmd.Dispose(); res.Write(JsonConvert.SerializeObject(dt).ToString());
res.End(); } private Dictionary<String, Object> GetParameter(HttpContext context)
{
StreamReader reader = new StreamReader(context.Request.InputStream);
String strJson = HttpUtility.UrlDecode(reader.ReadToEnd());
JavaScriptSerializer jss = new JavaScriptSerializer();
Dictionary<String, Object> dicParameter = jss.Deserialize<Dictionary<String, Object>>(strJson);
return dicParameter;
} public bool IsReusable
{
get
{
return false;
}
}
}
}

项目中Ajax调用ashx页面中的Function的实战的更多相关文章

  1. jQuery中ajax调用当前页面方法

    $.ajax({ type: 'POST', url: 'AddressManager.aspx/GetProvince',//AddressManager.aspx当前页面 data: '{cach ...

  2. 使用反射机制实现jQuery调用ashx类中的指定方法

    使用反射机制实现jQuery调用ashx类中的指定方法   近期用asp.net做个小网站,但又不喜欢使用asp.net的服务器端控件,经过一番思量后确定前端采用原始的html.后台采用Linq to ...

  3. jquery.ajax请求aspx和ashx的异同 Jquery Ajax调用aspx页面方法

    1.jquery.ajax请求aspx 请求aspx的静态方法要注意一下问题: (1)aspx的后台方法必须静态,而且添加webmethod特性 (2)在ajax方法中contentType必须是“a ...

  4. 在子jsp页面中调用父jsp中的function或父jsp调用子页面中的function

    项目场景: A.jsp中有一个window,window里嵌入了一个<iframe>,通过<iframe>引入了另一个页面B.jsp.在B.jsp中的一个function中需要 ...

  5. Jquery Ajax调用aspx页面方法

    Jquery Ajax调用aspx页面方法 在asp.net webform开发中,用jQuery ajax传值一般有几种玩法 1)普通玩法:通过一般处理程序ashx进行处理: 2)高级玩法:通过as ...

  6. Ajax调用处理页面错误信息500的解决思路

    最近在做项目的时候遇到一个问题:(李昌辉) 在本地服务器上做好之后,部署到阿里云虚拟主机,结果访问页面出现问题,由于登录使用的是AJAX调用处理页面,所以在点击登录的时候没有任何反应. 打开F12调试 ...

  7. js 和 css 中 不能使用 jsp 页面中一些 标签 和 java 代码等,应注意

    js  和 css 中 不能使用 jsp  页面中一些 标签 和 java 代码等,应注意 如 ${ }  <%%>  等

  8. jQuery 互相调用iframe页面中js的方法

    1,子iframe内调用父类函数方法: window.parent.func(); 2,子Iframe中获取父界面的元素: $("#xx", window.parent.docum ...

  9. ashx页面中context.Session["xxx"]获取不到值的解决办法

    在 aspx和aspx.cs中,都是以Session["xxx"]="aaa"和aaa=Session["xxx"].ToString()进 ...

随机推荐

  1. flask笔记---url、变量规则

    1.路由: route() 装饰器用于把一个函数绑定到一个 URL,可以动态变化 URL 的某些部分,还可以为一个函数指定多个规则,从而方便用户访问与记忆. 例子: @app.route('/') # ...

  2. TF-IDF 加权及其应用

    TF-IDF 加权及其应用 TF-IDF(term frequency–inverse document frequency)是一种用于资讯检索的常用加权技术.TF-IDF是一种统计方法,用以评估某个 ...

  3. 查找“CDN、负载均衡、反向代理”等大型网络真实IP地址的方法

    首先,CDN.负载均衡.反向代理还分为很多层,有时查出来的是最外层的 CDN 服务器群,真实的机器是不对外开放的,类似这样的: 用户 → CDN 网络 → 一台或多台真实机器 ↗ CDN Server ...

  4. Python之路【第五篇续】:面向对象编程二

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABgQAAALaCAIAAABxja8cAAAgAElEQVR4nOzd6X9Tdd74/+uv+f5uzF

  5. step 4 GCD 队列演练

    串行队列 特点 以先进先出的方式,顺序调度队列中的任务执行 无论队列中所指定的执行任务函数是同步还是异步,都会等待前一个任务执行完成后,再调度后面的任务 队列创建 dispatch_queue_t q ...

  6. linux下定时执行任务方法【转】

     之前就转过一篇关于定时任务的文章,前俩天用,还的翻出来看!!!再转一次,备用,,需要的时候不用麻烦找! ----------------------------------------------- ...

  7. MySql循环插入数据(定义了存储过程)

    MySQL一窍不通啊,今天工作上需要用到,请教了别人,做以备忘 DROP PROCEDURE test_insert ; DELIMITER ;; CREATE PROCEDURE test_inse ...

  8. 开始使用 Markdown

    (Xee:我最近感觉nyfedit打开有点慢,数据库有点大,试想着用一些其他的方式记录一下学习的过程,才想起了遗忘了很长时间的Markdown,将其分类在HTML下,也是我原本意愿的...) 本文面向 ...

  9. POJ 2299 Ultra-QuickSort

    离散化+树状数组求逆序数 Ultra-QuickSort Time Limit: 7000MS Memory Limit: 65536K Total Submissions: 35024 Accept ...

  10. soj4271 Love Me, Love My Permutation (DFS)

    4271: Love Me, Love My Permutation Description Given a permutation of n: a[0], a[1] ... a[n-1], ( it ...