Thursday, 29 August 2013

Loading different HTML code into one single page on different link clicks

Loading different HTML code into one single page on different link clicks

So, my boss has this crazy idea - the whole website working on one single
page. So far - still ok, but here's the thing: - the different pages have
different divs with content (like usual), and when some div is clicked (or
link in it) some of the divs expand/collapse, working in the way of
revealing different content. That's fine, but...
he doesn't want to use JavaScript or anything for dynamic view of the
website ('cuz I am leaving in 2 weeks and him and the other employee are
not capable of JS, thus cannot improve/maintain if needed)
his idea is to have the HTML code, for all the pages variations of the
website, stored in the database, and upon clicking some link - reloading
the page with the certain HTML. So not different .html files for every
page, but only one for all of them.
The problem is that it works for the first page that I load, initially,
but then when I call another page, it gets twisted, since I call the
function, that retrieves the HTML, but the other call of the previously
loaded page is still there, so it calls again. Here's sample, so you
understand:
<script runat="server" type="text/C#">
public string getPage(string name)
{
string page = "null";
switch (name)
{
case "media":
page = getMediaPage(); <!-- just function from the
code-behind that retrieves the html code from the DB and
passes it to the page -->
break;
case "home":
page = getHomePage(); <!-- just function from the
code-behind that retrieves the html code from the DB and
passes it to the page -->
break;
}
return page;
}
</script>
</head>
<body onload="addEvents();">
<form id="form1" runat="server">
<div id="parent">
<div id="presentation">
SomeCompany
ApS&nbsp;&nbsp;&nbsp;Street3&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;CITY&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;INFO@Comapny.com&nbsp;&nbsp;&nbsp;TLF:
999999
</div>
<%=getPage("home") %>
</div>
</form>
So that's how the initial page will be and then just in the parent div I
will call the HTML for the other pages. One example of HTML, stored in the
DB:
<div id="mainmenu">
<b>HOME</b>
<br />
PRODUCTS
<br />
<a href="<%=getPage("media")%>">SUPPORT</a>
<br />
CONTACT
<br />
ABOUT
<br />
</div>
<div id="logo">
</div>
So I call this chunk of code slam it in the page. The twist happens as I
have <a href="<%=getPage("media")%>"> clicked, so it loads the page
normally, but there is <%=getPage("home") %> standing statically in the
page, ALL THE TIME, as I need to start from somewhere, and it attempts to
load the previous page again, and... server error.
I know it's kinda stupid idea, but I can't argue with him anymore.
So my question is - is there way of handling all this with some kind of
OnClick(Event e) or some other way out, with calling different functions
(as I already started). Or I should just tell the boss that it's not gonna
work this way...

No comments:

Post a Comment