Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

i am using imageslider for showing image and some data using asp:repeater, but when i click on any image slider comes his starting (actual) position, i want to stop it to come image slider in it's starting position . image slider is in updatepanel and one javascript function call.

javascript function call outsideupdatepanel:

JavaScript
function pageLoad()
               {
               $(function () {
               $('#mycarousel').jcarousel();
               });
       }


and aspx code inside updatepanel:

ASP.NET
<ul id="mycarousel">
                                            <asp:Repeater ID="rptImages" runat="server">
                                                <itemtemplate>
                                                    <li>
                                                        <asp:ImageButton ID="img" alt="" runat="server" OnClick="SelectDataUsingImage" CommandArgument='<%# Eval("TstText4") %>'
                                                            src='<%# Eval("ImageUrl") %>' />
                                                       <asp:LinkButton ID="Label2" Text='<%# Eval("TstText1") %>' OnClick="SelectDataUsingText"
                                                            CommandArgument='<%# Eval("TstText4") %>' runat="server">
                                                        <br>
                                                        <asp:LinkButton ID="Label1" Text='<%# Eval("TstText2") %>' OnClick="SelectDataUsingText"
                                                            CommandArgument='<%# Eval("TstText4") %>' runat="server" >
                                                        <br>
                                                        <asp:LinkButton ID="Label3" Text='<%# Eval("TstText3") %>' OnClick="SelectDataUsingText"
                                                            CommandArgument='<%# Eval("TstText4") %>' runat="server" >
                                                   </br></br></li>
                                                </itemtemplate>
                                            
                                        </ul>



please help.


thanks
shubham gupta
Posted
Updated 2-Sep-15 2:12am
v2

1 solution

XML
<asp:ImageButton ID="img" alt="" runat="server" OnClick="SelectDataUsingImage" CommandArgument='<%# Eval("TstText4") %>' src='<%# Eval("ImageUrl") %>' />
Check this OnClick Event. You are doing something here, which might be rebinding the Repeater. If this call is not required, then remove it.
 
Share this answer
 
Comments
Member 11449483 3-Sep-15 1:15am    
NO sir, i am not using anything that rebind the repeater in this onclick function.

Thanks
Then are you rebinding the repeater inside Page Load? Can you post the Page Load code here?
Member 11449483 4-Sep-15 0:39am    
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Page.IsPostBack Then
ScriptManager.RegisterClientScriptBlock(Page, Me.[GetType](), "CallJS", "afterpostback();", True)
End If
If Not Page.IsPostBack Then
PopulateProjectGridView()
ShowHideContentAccordingToUserRole() ''Call this method after binding the gridview.
GetCustomizationSetting()
loadProjectDashBoard() 'Load image slider using repeater
Else
Me.SqlDataSource.SelectCommand = Session("SqlDataSourceCommand")
End If
CreateParkerDetailsButton(GVSelectedindex.Value)
ShowAndHideClearFilterCtrl()
End Sub


Please see link this jquery function on pageload():
http://cdn.jsdelivr.net/jcarousel/0.2.8/jquery.jcarousel.js

image slider example ref:
http://www.aspforums.net/Threads/330240/Creating-a-Slideshow-Image-Gallery-using-ASPNet-Repeater-and-jQuery-Carousel-Plugin/

Hello sir i am using above ref and modify our code and bind repeater with database but after page pastback
repeater takes his starting position. please help me out.

Private Sub loadProjectDashBoard()
Dim dt As New DataTable()
Dim DataInterface As New DataInterface
Dim ds As New DataSet()
ds = DataInterface.getprojectdetail(GridCommand) 'GridCommand is sqlquery
dt.Columns.AddRange(New DataColumn(0) {New DataColumn("ImageUrl")})
dt.Columns.AddRange(New DataColumn(0) {New DataColumn("TstText1")})
dt.Columns.AddRange(New DataColumn(0) {New DataColumn("TstText2")})
dt.Columns.AddRange(New DataColumn(0) {New DataColumn("TstText3")})
dt.Columns.AddRange(New DataColumn(0) {New DataColumn("TstText4")})
For i = 0 To ds.Tables(0).Rows.Count - 1
If (i < 10) Then ' bind 10 rows data and repeater shows first 5 at starting position and other 5 after scrolling
If (ds.Tables(0).Rows(i).Item("Status") = "Completed") Then
dt.Rows.Add(ResolveUrl("~/Images/Small/CompletedProject.png"), ds.Tables(0).Rows(i).Item("ProjectCode").ToString, ds.Tables(0).Rows(i).Item("partNo").ToString, "Completed: " & ds.Tables(0).Rows(i).Item("EndDate"), ds.Tables(0).Rows(i).Item("RevisionID").ToString)
ElseIf (ds.Tables(0).Rows(i).Item("Status") = "Running") Then
dt.Rows.Add(ResolveUrl("~/Images/Small/RunningProject.png"), ds.Tables(0).Rows(i).Item("ProjectCode").ToString, ds.Tables(0).Rows(i).Item("partNo").ToString, "Running: " & ds.Tables(0).Rows(i).Item("EndDate"), ds.Tables(0).Rows(i).Item("RevisionID").ToString)
Else
dt.Rows.Add(ResolveUrl("~/Images/Small/FailedProject.png"), ds.Tables(0).Rows(i).Item("ProjectCode").ToString, ds.Tables(0).Rows(i).Item("partNo").ToString, "Failed: " & ds.Tables(0).Rows(i).Item("EndDate"), ds.Tables(0).Rows(i).Item("RevisionID").ToString)
End If
Else
Exit For
End If
Next
rptImages.DataSource = dt
rptImages.DataBind()
End Sub

Protected Sub SelectDataUsingImage(ByVal sender As Object, ByVal e As EventArgs)
'Get the reference of the clicked button.
Dim button As ImageButton = CType(sender, ImageButton)
Dim i As Integer = 0
'Get the command argument
commandArgument = button.CommandArgument

'Dim item As RepeaterItem = CType(button.NamingContainer, RepeaterItem)
CreateParkerDetailsButtonstring(commandArgument)
ShowAndHideClearFilterCtrl()
Tbl_Info.Style(display) = "block"
PopulateProjectDetailsTable(commandArgument)

Dim SqlDataSourceCommand As String = GridCommand & "ORDER BY StartDate DESC"
'GridView_Project_RowDataBound(sender, e)
Me.SqlDataSource.SelectCommand = SqlDataSourceCommand

End S

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



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