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..