• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 473
  • Last Modified:

assign div inner contents dynamically - from another web page (aspx)

<div id="divinnercontent" runat="server">

[[ content from an aspx page ]]

</div>



This part:   [[ content from an aspx page ]]

I want to change based upon a click on a hotspot in an image map.
0
Tom Knowlton
Asked:
Tom Knowlton
  • 5
  • 3
1 Solution
 
wht1986Commented:
use XmlHttpRequest, an example can be found http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm
0
 
wht1986Commented:
just in case, whatever javascript function you create to initiate the XmlHttpRequest, your hotspots would call it via the onClick event of the tag

<area shape ="circle" coords ="90,58,3" onClick="GetDetails( 'mydetailurl1.html' );"  .....   />
<area shape ="circle" coords ="56,23,3" onClick="GetDetails( 'mydetailurl2.html' );"  .....   />
0
 
Tom KnowltonWeb developerAuthor Commented:
What if I wanted to do this in the code-behind?
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
Tom KnowltonWeb developerAuthor Commented:
For example:

 protected void ImageMap1_Click(object sender, ImageMapEventArgs e)
    {
      if (e.PostBackValue.Contains("services"))
      {
        divinnercontent.InnerHtml = [[[ GET INNTER HTML FROM SERVICES.ASPX ]]]
           
      }
    }
0
 
wht1986Commented:
Ah, even easier.

1) if the file is on the same server, you could read the file into a string and set divinnercontent.innerHTML = "mystringhere";

2) If its on remote location, you can use the WebRequest object to read in the remote page into a string
http://msdn.microsoft.com/en-us/library/system.net.webrequest.aspx

3) Place an IFrame in the div and set the href location of the iframe to be your desired page
0
 
wht1986Commented:
if you need only a particular div out of 'remote' page, you can use some XML goodness.

string pageHtml = "what ever the full html from the page is"

XmlDocument doc = new XmlDocument();
doc.LoadXml(pageHtml);

then you can use some methods to find the div.  If the remote div of interest is called 'woohoo1' then

XmlElement elem = doc.GetElementById("woohoo1");

divinnercontent.innerHTML = elem.innerHTML;
0
 
wht1986Commented:
Any of those suggestions help?
0
 
Tom KnowltonWeb developerAuthor Commented:
The iframe suggestion worked. Now my problem is with formatting, but that will be a new question.  :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now