In order to achieve the functionality of refreshing ListView No.2 without refreshing the entire page when a user clicks on an item in ListView No.1, I am attempting to use JavaScript. Here is what I have tried so far:
ListView No.1:
<asp:ListView ID="LeftsideMessageList" runat="server" ItemPlaceholderID="itemPlaceHolder1" DataKeyNames="id" OnSelectedIndexChanged="LeftsideMessageList_SelectedIndexChanged" >
ListView No.2 (which refreshes every time any item in ListView No.1 is clicked/selected)
<asp:UpdatePanel ID="videosUpdatePanel" runat="server" OnLoad="videosUpdatePanel_Load" >
<ContentTemplate>
<asp:ListView ID="videosListView" runat="server" ItemPlaceholderID="itemPlaceHolder1">
//List view items and stuff
</ContentTemplate>
</asp:UpdatePanel>
Here is the JavaScript code I am using:
<script
type="text/javascript"> function GetVideos() { __doPostBack("<%=videosUpdatePanel.UniqueID %>", ""); }
</script>
To trigger the OnLoad method of the videosUpdatePanel from the GetVideos() JavaScript function, I have the following code:
protected void videosUpdatePanel_Load(object sender, EventArgs e)
{
string email = Session["Username"].ToString();
List<Activity> videos = BC.getMediaOfUser(email, "Video");
videosListView.DataSource = videos;
videosListView.DataBind();
}
The desired procedure is as follows:
Click/Select any item from ListView No.1 -> Call the GetVideos() JavaScript -> Call Update panel's OnLoad to refresh ListView No.2
The challenge I am facing is figuring out how to invoke the GetVideos() function as ASP ListViews do not have an OnClick method. What is the appropriate method to trigger ListView No.1's OnItemClick?