I find it frustrating how hard it B to remember all these syntaxes, when all you want to do is add some quick code into your html. So here is how you add some code into your HTML aspx file
<script> does not work but <% ...%> does.
And here is some code which identifies the current page, path and strips them into separate parts:
<%
string sPath = Request.ServerVariables["PATH_INFO"];
string sPage;
string sWebPath;
//-- Before capitlaizing get the path from the string
sWebPath = sPath;
//-- Capitalize for easy searching
sPath = sPath.ToUpper();
//-- Find the page name
sPage = sPath.Remove(0,sPath.LastIndexOf("/")+1);
//-- Find the webpath
sWebPath = sWebPath.Remove(sPath.IndexOf(sPage));
if (sPath.Contains("DEFAULT.ASPX")){
Response.Write("do something on the home page");
}
else {
Response.Write("do something on the other pages");
}
%>
Reference site worth a visit W3 Schools - Server Variables
Comments