Specify which xml file to load when link is clicked

Posted by Jason on Stack Overflow See other posts from Stack Overflow or by Jason
Published on 2012-08-30T09:36:25Z Indexed on 2012/08/30 9:38 UTC
Read the original article Hit count: 307

Filed under:
|
|
|

Good morning,

I would like it so when a link is clicked on the homepage it would load a particular xml file into the next page (the page is called category-list.apsx).

This category list page uses the Repeater Control method to display the xml details on the page. I used the example shown here:

http://www.w3schools.com/aspnet/aspnet_repeater.asp

So at the moment the repeater script looks like:

<script runat="server">
    sub Page_Load
    if Not Page.IsPostBack then
       dim mycategories=New DataSet
       mycategories.ReadXml(MapPath("categories.xml"))
       categories.DataSource=mycategories
       categories.DataBind()
    end if
    end sub
</script>

After doing some research I did find someone with the same problem and the solution was to insert #tags as part of the link on the homepage (i.e. category-list.apsx#company1results) and then some script on the list page to pick up the correct xml file:

<script type="text/javascript">
    var old_onload = window.onload; // Play it safe by respecting onload handlers set by other scripts.
    window.onload=function()
    {
     var categories = document.location.href.substring(document.location.href.indexOf("#")+1);
     loadXMLDoc('XML/'+categories+'.xml');
     old_onload();
    }
</script>

This was from the following link:

http://www.hotscripts.com/forums/javascript/45641-solved-specify-xml-file-load-when-click-link.html

How can I get these two scripts to connect with each other?

Thank you for your time

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about ASP.NET