Reputation: 119
How can i update a repeater on my masterpage, through an ajax webmethod? I'm having trouble finding the masterpage in my webmethod.
Edit: Is there a better way to do this? Basicly i want to update the repeater after running my ajax webmethod login script.
MasterPage Jquery:
<script type="text/javascript">
$(document).ready(function () {
$('#btn_logout').click(function () {
$.ajax({
type: "POST",
url: "Webmethods.aspx/logIn",
data: '{username: "' + username + '", password: "' + password + '"}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
// UPDATE REPEATER DATA
}
}
}
</script>
MasterPage Repeater:
<asp:Repeater ID="Repeater_Menu" runat="server">
<ItemTemplate>
</itemTemplate>
</asp:Repeater>
Edit: Not a single answer to this relatively simple question?
Upvotes: 1
Views: 462
Reputation: 13965
Unless things have changed significantly, WebMethods are static methods. So they will not have access to any properties or fields of the page they are part of - and that includes the objects on the master page.
Another obstacle to this is that things done with AJAX on the server do not affect the HTML that has already been rendered to the client. To change the appearance on the client, you will need to use javascript (presumably jQuery).
What you might be able to do is this:
Repeater
control in codeRepeater
with the new HTML.Upvotes: 1