yogeswaran K
yogeswaran K

Reputation: 2288

How to pass the parameter to same page using java script in Asp.net

How to pass the parameter to same page using java script in Asp.net

top.location.href = '/IFGE/DeleteAllPrice/' + id;

is working fine for redirecting to other pages but not working for redirecting to same page

Upvotes: 5

Views: 11628

Answers (4)

Giddy Naya
Giddy Naya

Reputation: 4658

What if the page url already has "?" or includes some parameters. The selected answer would result to a malformed URL since it just appended to some existing queries. Do this instead;

window.location.href = window.location.href.split("?")[0] + "?ID=" + someid ;

Upvotes: 3

user1312242
user1312242

Reputation: 337

Its better to Use AJAX with http - Post method, and post parameter to the Server.

Something like: (Do Not copy and paste below code. Please research more on this procedure)

var myObject = new Object();
myObject.FirstName = "david";
myObject.LastName = "Jones";
XmlHttpRequest vXHRequest = new XmlHttpRequest();
..
..
..
vXHRequest.send(myObject);

in asp.net aspx page page_load,

Dictionart dict = JavaScriptSerializer.DeSerialize<Dictionary>(Request.Params["myObject"]);

Upvotes: -3

jordi
jordi

Reputation: 51

If I understand you correctly, you try to refresh/reload the page?

Try one of this:

  • window.location.reload();
  • history.go(0);
  • window.location.href=window.location.href;

Upvotes: 0

Habib
Habib

Reputation: 223257

window.location.href = window.location.href + "?ID=" + someid ;

You need to append window.location.href

Upvotes: 7

Related Questions