Hi power,
Change with Below code.
HTML
Default
<asp:Button ID="Home" Text="Home" runat="server" OnClick="Home_Click" />
<asp:Button ID="Photo" Text="Photo" runat="server" OnClick="Photo_Click" />
Global.asax
C#
<%@ Application Language="C#" %>
<%@ Import Namespace="System.Web.Routing" %>
<script RunAt="server">
void Application_Start(object sender, EventArgs e)
{
RegisterRoutes(RouteTable.Routes);
}
static void RegisterRoutes(RouteCollection routes)
{
routes.MapPageRoute("Default", "Default", "~/Default.aspx");
routes.MapPageRoute("Homes", "Homes", "~/Home/Home.aspx");
routes.MapPageRoute("Photo", "Photo", "~/Home/Photo/Photo.aspx");
}
</script>
VB.Net
<%@ Application Language="VB" %>
<%@ Import Namespace="System.Web.Routing" %>
<script RunAt="server">
Private Sub Application_Start(sender As Object, e As EventArgs)
RegisterRoutes(RouteTable.Routes)
End Sub
Private Shared Sub RegisterRoutes(routes As RouteCollection)
routes.MapPageRoute("Default", "Default", "~/Default.aspx")
routes.MapPageRoute("Homes", "Homes", "~/Home/Home.aspx")
routes.MapPageRoute("Photo", "Photo", "~/Home/Photo/Photo.aspx")
End Sub
</script>
Code
Default
C#
protected void Home_Click(object sender, EventArgs e)
{
Response.Redirect("~/Homes");
}
protected void Photo_Click(object sender, EventArgs e)
{
Response.Redirect("~/Photo");
}
VB.Net
Protected Sub Home_Click(sender As Object, e As EventArgs) Handles Home.Click
Response.Redirect("~/Homes")
End Sub
Protected Sub Photo_Click(sender As Object, e As EventArgs) Handles Photo.Click
Response.Redirect("~/Photo")
End Sub
Screenshot