Go Back   CodingForums.com > :: Server side development > ASP.NET

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-23-2006, 11:59 AM   PM User | #1
snow
New Coder

 
Join Date: Jun 2005
Location: Scotland
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
snow is an unknown quantity at this point
Question JavaScript if problems with XML

Heya,

In my code at the moment I have a repeater that's getting values from my XML document and displaying them in a table. I wanted to exclude some of these values so that they only appeared once and I decided to use a JavaScript if statement to do it, this is what I came up with:

Code:
      <script language="jscript">
        var store = nil;
        var framec = nil;
      </script>
      <asp:XmlDataSource id="ds1" runat="server" DataFile="XMLFile.xml" />
      <asp:repeater ID="repeater1" DataSourceid="ds1" runat="server">
        <HeaderTemplate><table></HeaderTemplate>
        <ItemTemplate>
         script language="jscript">
            document.write("test");
            if ((store!=(<%#XPath("@type")%>)) || (framec != <%#XPath("@frame")%>)) {
              document.write('<tr><td>Framed <%#XPath("@type")%></td></tr>');
              store = <%#XPath("@type")%>;
              framec = <%#XPath("@frame")%>;
            }
            store = <%#XPath("@type")%>;
            framec = <%#XPath("@frame")%>;
          </script>          <tr>
            <td><%#XPath("@size")%></td>
            <td><asp:TextBox runat="server" Text='<%#XPath("width")%>'></asp:TextBox> X             
            <asp:TextBox ID="TextBox1" runat="server" Text='<%#XPath("height")%>'></asp:TextBox></td>
          </tr>
        </ItemTemplate>
        <FooterTemplate></table></FooterTemplate>
      </asp:repeater>

However, what it comes up with isn't quite what I had in mind. The javascript only seems to run for the last 3 entries of my XML, that "test" I put in the javascript only appears 3 times. The parts of my itemtemplate that are not in the JavaScript run fine, and I don't know why!

I'd be very grateful for any assistance!

Snow
snow is offline   Reply With Quote
Old 01-23-2006, 07:19 PM   PM User | #2
snow
New Coder

 
Join Date: Jun 2005
Location: Scotland
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
snow is an unknown quantity at this point
Smile

Well, I got it fixed... the problem was to do with my XML file I believe (and some dodgy JavaScript coding), but it's doing exactly what I wanted it to do now!

Sorry for bothering ya all!

Snow
snow is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:55 PM.


Advertisement
Log in to turn off these ads.