0

I'm coding an application with JQuery Mobile and ASP.NET. I have a page with this code:

<asp:ListView ID="accountsListView" runat="server" DataSourceID="XmlDataSource1">
    <LayoutTemplate>
        <div id="itemPlaceHolderContainer" runat="server">
            <ul data-role='listview' data-theme='c' data-inset='true'>
                <span id="ItemPlaceHolder" runat="server" />
            </ul>
        </div>
    </LayoutTemplate>
    <ItemTemplate>

        <li>
            <a href='Account_Details.aspx'><h1><%#XPath("name")%></h1>
            <p><%#XPath("location")%></p> 
            </a>
        </li>

    </ItemTemplate>
</asp:ListView>
<asp:XmlDataSource ID="XmlDataSource1" runat="server" 
    DataFile="~/accountlist.xml"></asp:XmlDataSource>

This creates a list from my xml file of accounts. I want to have the user select an account and have the page send the node path to another page so I can display all information about the individual account. I'm kind of stuck on how exactly I should go about doing this.

A sample of the xml file is this:

<?xml version="1.0" encoding="ISO-8859-1"?>
 <AccountsList>
     <account>
      <name>Bubba Gump Shrimp Co.</name>
      <location>Alabama</location>
      <account_num>1986</account_num>
      <contact_name>Forrest Gump</contact_name>
      <contact_phone>555-555-5555</contact_phone>
     </account>
 </AccountsList>
Novacane
  • 119
  • 3
  • 14
  • 2
    You will need to be a lot more specific to get **good** answers! – gdoron Mar 09 '12 at 07:41
  • You'll have to include a sample of your XML, otherwise we can't know what the path should look like. – Michael Rice Mar 09 '12 at 07:47
  • Basically I need to know if there is a way to send the node information to another page when a user clicks a link. That page will then find the node in the xml file and display all the elements of the node. So for example if the user chooses "Account52", I want them to be redirected to the Account_details page and be able to show all the elements in "Account52" node. – Novacane Mar 09 '12 at 07:49
  • Updated with a sample of the xml – Novacane Mar 09 '12 at 07:57

1 Answers1

0

Just make an onclick handler and have that pass whatever data you want in a query parameter (or json data if you want). You may wish to style your div appropriately to make it look like a normal a tag.

 // skip the XML if you want and just use inline C# or vb
 <div id='blank-link' onclick='handleClick(" <%= myAccountId %> "'><%= myAccountName %></div>

 function handleClick( id ){        
    window.location.href = "MyAspPage.aspx?id=" + id;
 }

If you don't want to use query parameters, you should look into ASP.NET URL routing to parse out values by using just accounts/id etc. http://msdn.microsoft.com/en-us/library/cc668201.aspx

FlavorScape
  • 13,301
  • 12
  • 75
  • 117
  • Thank you this is exactly what I was looking for! Added an id element to my xml file so that it's easy to pass without having any actual information in the URL. – Novacane Mar 09 '12 at 22:22