Note that there are some explanatory texts on larger screens.

plurals
  1. POEndless scroll asp.net
    text
    copied!<p>abcI tried to create an endless scroll with a WebMethod but I always get a "failed" message. I checked my code and I didn't find any error. Here is my code:</p> <p>Code Behind:</p> <pre><code>public int CurrentPage { get { // look for current page in ViewState object o = this.ViewState["_CurrentPage"]; if (o == null) return 0; // default to showing the first page else return (int)o; } set { this.ViewState["_CurrentPage"] = value; } } protected void Page_Load(object sender, EventArgs e) { sqlConn.ConnectionString = ConfigurationManager.AppSettings["Database"]; ItemsGet("EN"); } [WebMethod] public void ItemsGet(string Language) { try { sqlConn.Open(); SqlDataAdapter myCommand = new SqlDataAdapter(@" Database query...", sqlConn); DataSet ds = new DataSet(); myCommand.Fill(ds); PagedDataSource objPds = new PagedDataSource(); objPds.DataSource = ds.Tables[0].DefaultView; objPds.AllowPaging = true; objPds.PageSize = 9; objPds.CurrentPageIndex = CurrentPage; Repeater1.DataSource = objPds; Repeater1.DataBind(); } catch (Exception ex) { } } </code></pre> <p>ASPX:</p> <pre><code>&lt;asp:Repeater ID="Repeater1" runat="server"&gt; &lt;ItemTemplate&gt; &lt;ul class='hover_block'&gt; &lt;li style=''&gt; &lt;a style='width: 524px;margin-top:-1px;margin-left:-1px; height: 365px;border:1px solid #cecece; background-color: #ECecec;' href=' &lt;%#DataBinder.Eval(Container.DataItem,"RecID") %&gt;'&gt; &lt;img src='abc.com.tr/news/img/&lt;%#DataBinder.Eval(Container.DataItem,"Image1")%&gt;' alt='' class='left' style='margin-right: 10px; width: 500px; height: 300px;'/&gt; &lt;div class='Icerik'&gt; &lt;h3 class='News_Head'&gt; &lt;%#DataBinder.Eval(Container.DataItem,"Head") %&gt;&lt;/h3&gt; &lt;p style='font-family:Tahoma;'&gt; &lt;%#DataBinder.Eval(Container.DataItem,"Content") %&gt;&lt;/p&gt; &lt;b class='info'&gt;View More&lt;/b&gt; &lt;/div&gt; &lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/ItemTemplate&gt; &lt;/asp:Repeater&gt; </code></pre> <p>It is my script side:</p> <pre><code> &lt;script type="text/javascript"&gt; $(window).scroll(function () { if ($(window).scrollTop() == $(document).height() - $(window).height()) { $.ajax({ type: "POST", url: "default.aspx/ItemsGet", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", success: AjaxSucceeded, error: AjaxFailed }); function AjaxSucceeded() { alert("result.d"); } function AjaxFailed() { alert("Failed"); } } });&lt;/script&gt; </code></pre> <p>Why does it fail? I always get alert("Failed") while scrolling.Please help! Thanks for your answers</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload