Skip to content

Instantly share code, notes, and snippets.

@WildGenie
Created May 29, 2018 23:36
Show Gist options
  • Save WildGenie/bfe41f1fd49cf18c095758c5f9b567f8 to your computer and use it in GitHub Desktop.
Save WildGenie/bfe41f1fd49cf18c095758c5f9b567f8 to your computer and use it in GitHub Desktop.
Web Form Routes Örnek
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="altkategori.aspx.cs" Inherits="altkategori" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>
ID:
<asp:Literal ID="ID"
Text="<%$RouteValue:id%>"
runat="server">
</asp:Literal>,
<asp:Literal ID="IDKod"
runat="server">
</asp:Literal>
</h1>
</div>
</form>
</body>
</html>
using System;
using System.Web.UI;
public partial class altkategori : Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Page.RouteData.Values["id"] == null)
{
IDKod.Text = "ID Yok";
}
else
{
IDKod.Text = Page.RouteData.Values["id"].ToString();
}
}
}
<%@ Application Language="C#" %>
<%@ Import Namespace="System.Web.Routing" %>
<script RunAt="server">
private void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
RegisterRoutes(RouteTable.Routes);
}
private void RegisterRoutes(RouteCollection routes)
{
routes.MapPageRoute(string.Empty, "altkategori/id/{id}", "~/altkategori.aspx");
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment