Vishal Singh

Vishal Singh

  • NA
  • 12
  • 9k

how to call global asax route on code behind button click

Apr 29 2016 2:18 AM
 i have a button click event from i am doing to redirect in same page with different url  and i have a route for that url in global asax file but its not working on button click
 
its only working on html anchor tag only how can i do that 
my code as follows
 
 global asax route
routes.MapPageRoute("mmmm2", "hotels/{id}/", "~/products.aspx"); 
routes.MapPageRoute("maincat123", "hotels/{id}/{city}/", "~/products.aspx"); 
 
 code behind
string subcat = Page.RouteData.Values["id"].ToString();
HtmlButton btn = sender as HtmlButton;
HtmlInputText txt = btn.Parent.FindControl("Text2") as HtmlInputText;
string city = txt.Value;
string url = "hotels/" + subcat + "/" + city + "/";
Session["temp"] = url;
Response.Redirect(url);
 

Answers (4)