I am trying to pass querystring value from one of the gridview item on click to another web page 'Uncoated_wire.aspx.cs', here I want to use that value inside a web method 'GetCustomers' .how to achieve that. 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>
The highlighted star mark code line is used for passing value to another web page 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;
}
In this web method I want to access that querystring parameter how to do that.Any idea wouldd be appreciated
Try this code to get querystring from WebMethod.
[WebMethod]
public static string GetCustomers()
{
string strId = HttpContext.Current.Request.QueryString["Id"];
//dosomething
}
Hope this helps!