page 1 of 1
Comments: 8 | Views: 1228
turrican
turrican
Condemnation without investigation is the height of ignorance! - Albert Einstein

I got an index page with a DIV called "content", how to load an external URL ( but in the same domain ), get the InnerHTML(?) of it and then push it out to the DIV.InnerHtml? Only the loading of an external URL part will do since I already the "AJAX" code to fill DIVs with content.

Just trying to like, prevent page loads, not sure if I'm doing it the right way.

As in, if I got an index and I want a "login.aspx" module to load in it somehow, what to do? I mean, includes seem a bit "old way" of doing it. and I don't want a copy of my index for every module? *confused*

Edit : For example imagine you got a menu on top, how do I "include" this menu in all of my pages?!

Thanks!

Hi Turrican,
So you want one page which has a div on then to retrieve html from another page client side.

There is a couple of options that come to mind:

Function with webmethod attribute + System.Net.WebClient?
http://msdn.microsoft.com/en-us/magazine/cc164115.aspx
http://www.experts-exchange.com/Programming/Languages/Scripting/JScript/Q_23452309.html

XMLhttprequestobject (fiddly and has some caching issues)
http://www.15seconds.com/issue/020606.htm

This will be work for simple content but you will run into issues with more complex controls where you need viewstate etc.

Alex
stevo_
stevo_
Casablanca != Manchester

Turrican, you might be coming at this from the wrong side, while you say you want to avoid page loads thats file, but when you talk about includes to avoid having repeating information.. this just screamed out to me that you maybe aren't aware of:

Master pages

stevo_
stevo_
Casablanca != Manchester

Thats only happening because your controls are now sat in a parent control, that would well happen without a master page if you are using server side controls then their client side id is their hierical id (their id, their parents id and so on)..

You should be using ClientID to determine the correct client side id on a webforms application, and javascript in external files should not be aware of the pages structure.. you should instead have stubs on the page that initialize your javascript functionality.. so you would have your js that has a method which takes an element or id as an argument, and then from your page code, you have a small script tag that finds the element or tag, and calls into that js method..

For example, in supercoolwowjavascripteffects.js you might have

function makeElementExplodeWow(element) {
  .. insert code here to make explodes happen on element ..
}

then on your page you would have

<script>
var explodingElement = document.getElementById("<%= txtName.ClientID %>");
makeElementExplodeWow(explodingElement);
</script>