尝试访问 web 方法中的查询字符串值
Trying to access querystring value in web method
我试图将查询字符串值从一个 gridview 项目点击传递到另一个网页 'Uncoated_wire.aspx.cs',这里我想在 web 方法中使用该值 'GetCustomers'。如何实现那。
tad.aspx
<script type="text/javascript">
$(function () {
$("#THistory").click(function (event) {
event.preventDefault();
$("#pdfFormInsideL1").hide();
document.getElementById('<%=gvCustomers.ClientID%>').style.display = 'block';
//$("#gvCustomers").show();
$("#gvCustomers").attr("visibility", "visible");
$.ajax({
type: "POST",
url: "TDC.aspx/GetCustomers",
data: '{}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function (response) {
alert(response.d);
},
error: function (response) {
alert(response.d);
}
});
});
function OnSuccess(response) {
var xmlDoc = $.parseXML(response.d);
var xml = $(xmlDoc);
var customers = xml.find("Table");
var row = $("[id*=gvCustomers] tr:last-child").clone(true);
$("[id*=gvCustomers] tr").not($("[id*=gvCustomers] tr:first-child")).remove();
$.each(customers, function () {
var customer = $(this);
//$("td", row).eq(0).html($(this).find("TDC_NO").text());
$("td", row).eq(0).find("a").text($(this).find("TDC_NO").text());
***$("td", row).eq(0).find("a").attr("href", "Uncoated_Wire.aspx?Id=" + $(this).find("TDC_NO").text()).attr('target', '_blank');***
$("td", row).eq(1).html($(this).find("REVISION").text());
$("td", row).eq(2).html($(this).find("REVISION_DATE").text());
$("td", row).eq(3).html($(this).find("P_GROUP").text());
$("[id*=gvCustomers]").append(row);
row = $("[id*=gvCustomers] tr:last-child").clone(true);
});
}
});
</script>
突出显示的星号代码行用于向另一个网页传递值uncoated_wire.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
string TDC_NO_VAL = Request.QueryString["Id"];
hdn_val.Value = TDC_NO_VAL;
}
[WebMethod]
public static string GetCustomers()
{
hdn_val.Value = TDC_NO_VAL;
}
在这个 web 方法中,我想访问那个查询字符串参数如何做that.Any 将不胜感激
尝试使用此代码从 WebMethod 获取查询字符串。
[WebMethod]
public static string GetCustomers()
{
string strId = HttpContext.Current.Request.QueryString["Id"];
//dosomething
}
希望对您有所帮助!
我试图将查询字符串值从一个 gridview 项目点击传递到另一个网页 'Uncoated_wire.aspx.cs',这里我想在 web 方法中使用该值 'GetCustomers'。如何实现那。 tad.aspx
<script type="text/javascript">
$(function () {
$("#THistory").click(function (event) {
event.preventDefault();
$("#pdfFormInsideL1").hide();
document.getElementById('<%=gvCustomers.ClientID%>').style.display = 'block';
//$("#gvCustomers").show();
$("#gvCustomers").attr("visibility", "visible");
$.ajax({
type: "POST",
url: "TDC.aspx/GetCustomers",
data: '{}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function (response) {
alert(response.d);
},
error: function (response) {
alert(response.d);
}
});
});
function OnSuccess(response) {
var xmlDoc = $.parseXML(response.d);
var xml = $(xmlDoc);
var customers = xml.find("Table");
var row = $("[id*=gvCustomers] tr:last-child").clone(true);
$("[id*=gvCustomers] tr").not($("[id*=gvCustomers] tr:first-child")).remove();
$.each(customers, function () {
var customer = $(this);
//$("td", row).eq(0).html($(this).find("TDC_NO").text());
$("td", row).eq(0).find("a").text($(this).find("TDC_NO").text());
***$("td", row).eq(0).find("a").attr("href", "Uncoated_Wire.aspx?Id=" + $(this).find("TDC_NO").text()).attr('target', '_blank');***
$("td", row).eq(1).html($(this).find("REVISION").text());
$("td", row).eq(2).html($(this).find("REVISION_DATE").text());
$("td", row).eq(3).html($(this).find("P_GROUP").text());
$("[id*=gvCustomers]").append(row);
row = $("[id*=gvCustomers] tr:last-child").clone(true);
});
}
});
</script>
突出显示的星号代码行用于向另一个网页传递值uncoated_wire.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
string TDC_NO_VAL = Request.QueryString["Id"];
hdn_val.Value = TDC_NO_VAL;
}
[WebMethod]
public static string GetCustomers()
{
hdn_val.Value = TDC_NO_VAL;
}
在这个 web 方法中,我想访问那个查询字符串参数如何做that.Any 将不胜感激
尝试使用此代码从 WebMethod 获取查询字符串。
[WebMethod]
public static string GetCustomers()
{
string strId = HttpContext.Current.Request.QueryString["Id"];
//dosomething
}
希望对您有所帮助!