<div runat="server">

PROKA

Well-known member
Joined
Sep 3, 2003
Messages
249
Location
Bucharest
OK so have a default.aspx page.
All I have in this page is a div

Code:
<div id="test" runat="server"></div>

doing some little magic in code behind I can insert html into that div. Ok.
What I want to do is to insert a whole page.html there and after the page is inserted, work with the <div runat="server"> from the page.html


lets say the page.html looks like this:

Code:
<div id="id1" runat="server"></div> <div id="id2" runat="server"></div>

first I want to replace the "test" div with the content from the page.html . then I want to use the id1 and id2 divs to work with .innerhtml = etc
(Im trying to do some kind of easy skinning system)

HOW?
 
Ok You didnt quite understood me.

So I use a literal control to inject html, but also I want to modify that html according to the database. I want to be able to work with divName.InnerHtml = ...
 
OK so have a default.aspx page.
All I have in this page is a div

Code:
<div id="test" runat="server"></div>

doing some little magic in code behind I can insert html into that div. Ok.
What I want to do is to insert a whole page.html there and after the page is inserted, work with the <div runat="server"> from the page.html


lets say the page.html looks like this:

Code:
<div id="id1" runat="server"></div> <div id="id2" runat="server"></div>

first I want to replace the "test" div with the content from the page.html . then I want to use the id1 and id2 divs to work with .innerhtml = etc
(Im trying to do some kind of easy skinning system)

HOW?


I dont think this will be able to be accomplished with .NET code. In order to reference an object, it must first exist. You will just receive compile errors because of this.

Think of it in the terms that if your page.html were to get erased, you would definitely not have those objects there, anymore.

In order to do this, you will need JavaScript.

Code:
var div1 = document.getElementById("id1");
var div2 = document.getElementById("id2");

In JavaScript, it has error detection and will just give you a page error if the document isnt there.

I do this all the time for my AJAX pages; its the only real solution that I know of.

~Derek
 
how does this help me?

I apologize, I elaborated and never finished.

To get page.html on the original div, you will need what is called the XMLHttpRequest object. It is used to go behind the scenes to grab content from pages.

Heres an explanation and some exampleds:

http://en.wikipedia.org/wiki/XMLHttpRequest

Oh, and you wont make any of your divs with "runat=server". (Your probably know this already, but I wanted to make sure to throw it out there so I cover all of my angles.)

Hope this helps!

EDIT: I forgot to mention that if you dont want to go the complete route of JavaScript and are very adament about using .NET technology for this, Microsoft released all of those nifty little AJAX controls. Ive never personally used them, but the head programmer at my job uses them all the time and he loves them. He doesnt understand why I like JavaScript so much.

~Derek
 
Back
Top