Click here to Skip to main content
15,881,882 members

how to make this javascript work with all pages in listview

ALNAJJARALI asked:

Open original thread
Welcome all:

I would like to ask you about this javascript, this is a peace of code:
XML
<ItemTemplate>
                    <td id="Td2" runat="server" style="border:solid; width:inherit; border-color:white; font-size:medium;">
                        name:
                        <asp:Label ID="nameLabel" runat="server" Text='<%# Eval("name") %>' />
                        <br />
                        category:
                        <asp:Label ID="categoryLabel" runat="server" Text='<%# Eval("category") %>' />
                        <br />
                        available_quantity:
                        <asp:Label ID="available_quantityLabel" runat="server" Text='<%# Eval("available_quantity") %>' />
                        <br />
                        <asp:Image ID="product_image" runat="server" ImageUrl='<%# Eval("photo") %>'  style="cursor:pointer" class="magnify" width="150" height="150" align="Bottom" />
                        <br />
                        Detailes:
                        <a href='<%# "ProductDetailes.aspx?product_id="+ Eval("product_id")  %>' rel="ajaxpanel" > See product details..</a>
                        <br />
                    </td>
                </ItemTemplate>

and this is a DataPager for this ListView:
XML
<asp:DataPager ID="DataPager1" runat="server" PageSize="15" >
                                    <Fields>
                                        <asp:NextPreviousPagerField ButtonType="Link" ShowFirstPageButton="True" ShowNextPageButton="False" ShowPreviousPageButton="False" />
                                        <asp:NumericPagerField />
                                        <asp:NextPreviousPagerField ButtonType="Link" ShowLastPageButton="True" ShowNextPageButton="False" ShowPreviousPageButton="False" />
                                    </Fields>
                                </asp:DataPager>

I installed a script in the page:
XML
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
<link rel="stylesheet" type="text/css" href="scripts/ddajaxsidepanel.css" />
<script src="scripts/ddajaxsidepanel.js">

it opens a new web page in nice panel, but it requires to add the property rel="ajaxpanel" for any link you would like to open it in this panel. I added this property in the listview as you can see from the code above.

the script works fine ONLY in the first page of listview, but when you hit 2 (page two) in the DataPager it doen't work, rather, it opens the link in the same page.

you can get the script from here:
http://www.dynamicdrive.com/dynamicindex17/ajaxsidepanel.htm[^]

please any help to make the script works for all pages in the listview would be appreciated :)
Best regards.
Tags: Javascript, ASP.NET, ListView

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900