4
Answers

how to call global asax route on code behind button click

Vishal Singh

Vishal Singh

8y
319
1
 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)