Ako mam spravit skratene linky stylu /clanok.aspx?id=123&farbapozadia=cierna. Lebo v PHP je to dostatocne jednoduche. A v asp som skusal vsetko mozem ale newiem ako.
-----------------
DeaLer: titulek vlákna byl změněn, aby byl v souladu s obsahem.
Fórum › .NET
Náhrada include z PHP

To abcd: Co tím myslíš? Jak přistupovat k těm hodnotám?
if (this.Request.QueryString["id"] != null)
{
string identifier = this.Request.QueryString["id"];
}
Tvůj dotaz je velmi nekonkrétní a titulek taky nestojí za nic. Zapracuj na tom ... příště to smáznu.
Proste chcem mat stranku napr. Default.aspx. Bude tam design formatovanie proste vsetko co ma byt na hlavnej stranke. A chcem spravit napr link /Default.aspx?id=123. tym ze hlavni obsah bude obsahovat text co obsahuje nejaky subor 123. Proste chcem nieco taketo http://tvorba-webu.zdarek.com/php/include.php ale v ASP.
To je starej zlozvyk. Člověk vyleze z PHP a první, co hledá v ASP.NET je nějaký include. Samozřejmě tam není! V ASP.NET 2.0+ existují MasterPages (http://interval.cz/clanky/asp-net-2-0-master-pages/).
O master pages viem ale chcem nieco ako. http://www.w3schools.com/asp/asp_incfiles.asp.Ked spravim v asp stranku pomocou master pages sice vzhlad bude rovnaky ale budem mat vela suborov. Priklad spravim nejaky blog. Poslem nejaky clanok. Ked budem mat master page bude to /clanok/1234.aspx. ale to nechcem checme spravit /Default.aspx?clanok=1234. Nieco na taky styl.
Nevim, proč na tom trváš, ale budiž. Máš několik možností:
1. použít MasterPages + jednoduchej URL rewriting
2. dynamicky vkládat nějaký UserControly (s obsahem stránek)
3. napsat si vlastní ServerControl (myslím např. http://msdn2.microsoft.com/en-us/library/aa479009.aspx)
4. http://support.microsoft.com/default.aspx/kb/306575
Skus nieco taketo
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
private void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
if (Request["sec"] == "" || Request["sec"] == null)
{
}
else if (Request["sec"] == "1")
{
Response.Write("1");
}
else if (Request["sec"] == "2")
{
Response.Write("2");
}
else if (Request["sec"] == "3")
{
Response.Write("3");
}
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Untitled Page</title>
</head>
<body>
<%
if (Request["sec"] == null || Request["sec"] == "")
{
string identifier = this.Request.QueryString["sec"];
}
else if (Request["sec"] == "1")
{
string identifier = this.Request.QueryString["sec"];
}
else if (Request["sec"] == "2")
{
string identifier = this.Request.QueryString["sec"];
}
else if (Request["sec"] == "3")
{
string identifier = this.Request.QueryString["sec"];
}
%>
<form id="form1" runat="server">
<div>
1
</div>
</form>
</body>
</html>
a daj /Default.aspx?sec=1,/Default.aspx?sec=2,/Default.aspx?sec=3
To abcd : Není možný, že ti ani jedna z možností nefungovala ... pastni sem nějakej tvůj pokus, ať je nad čím diskutovat.
To tommyv580: Dik to funguje.
To DeaLer: Toto sa mi zdalo lahke ale nefungovalo mi to mozno som niekde spravil chybu http://www.codeproject.com/aspnet/URLRewriter.asp
Alebo tu mas nieco po cesky a je to dost jednoduche. http://www.fantomasmag.net/Clanky/69=url-rewriting-v-asp-net.aspx

Přidej příspěvek
Ano, opravdu chci reagovat → zobrazí formulář pro přidání příspěvku
×Vložení zdrojáku
×Vložení obrázku
×Vložení videa
































Uživatelé prohlížející si toto vlákno
Podobná vlákna
Php include url — založil tribalcz
Php - include in html — založil Dalkoplaz
PHP include a CSS — založil mik2
NAhrada Retazca — založil Marek
Nahrada retazca — založil Marek
Moderátoři diskuze