Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
I have a problem. I want replicate an effect "infity scroll". So I have an aspx page with inside an user control that load some row. When capture scroll event I want to load another user control with some other rows.
This is correct for me, but when after load some other post I try to click on a button I have an error on viewstate.
Is there anyone that can help me?

This is my code.


$("#full").scroll(
function () {

if ($("#full").scrollTop() >= ($("#container").height() - $("#full").height() + 170) && $contentLoadTriggered == false) {
$contentLoadTriggered = true;

$.ajax(
{
type: "POST",
url: "WebService.asmx/getValue",
data: '{ "prefixText": "' + $("#<%=elencoPostBacheca%>") + '" }',
contentType: "application/json; charset=utf-8",
dataType: "json",
async: true,
cache: true,
success: function (msg) {

$contentLoadTriggered = false;

$(".post").last().append("<table width='100%'><tr>" + msg.d + "</td</tr></table>");

},
error: function (x, e) {

}
}
);
}
}
);

});





[WebMethod(EnableSession = true)]
public string getValue(object prefixText)
{

using (Page page = new Page())
{
HtmlForm form = new HtmlForm();

// UserControl userControl = (UserControl)page.LoadControl("~/DynamicData/LoadMorePost.ascx");
UserControl userControl;

page.PreInit += new EventHandler((s, e) =>
{
userControl = (UserControl)page.LoadControl("~/DynamicData/LoadMorePost.ascx");
userControl.ID = "idControl1";
form.Controls.Add(userControl);
});
//form.Controls.Add(userControl);

using (StringWriter writer = new StringWriter())
{
page.Controls.Add(form);

try
{
HttpContext.Current.Server.Execute(page, writer, false);
}
catch (Exception err)
{
return "Error To Load Data";
}

return writer.ToString();
}
}

Thanks in advance..
Posted

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