Muhammed Athil Muhammed Athil -4 years ago 290
ASP.NET (C#) Question

PageMethods.SetPath() not working in routed url with url params

my page name is productdetails.aspx

In global.asax file I added custom routes like this

routes.MapPageRoute("ProductDetails", "ProductDetails/{Language}/{Currency}/{Store}/{ProductId}/{ProductName}", "~/ProductDetails.aspx");


I want to add PageMethods.SetPath Like

PageMethods.set_path(document.location.host+'/Home.aspx');


Not working

Answer Source

I got the answer my self When we are using PageMethods in routed url we need to take care of the location of path of the page where the code is existed. By using url routing the actual page may be in the root folder and the url be like "http://example.com/productdetail/en/usd/miami/121/dsm4". In this case when we are using PageMethods we need to write code for where the code existed in script. Eg:-

PageMethods.set_path("../../../yourpage.aspx");

Here I give (../) s to go back folder . Scrpt manager take url slases as folders and there may not be such folders.

For demo plz goto the link http://unclecoder.com/Article/40/Asp.net/PageMethodsRoutedUrl

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download