I am trying to retrieve thumbnails stored in folder and on clicking the new page will open to run video. Here is the code
<asp:DataList ID="DataList2" runat="server"
AutoGenerateColumns="false"
CellSpacing="5"
RepeatColumns="3"
Visible="true">
<ItemTemplate>
<u><%# Eval("videoTitle") %></u>
<hr />
<asp:ImageButton ID="ImageButton1" runat="server"
ImageUrl='<%# Eval("thumbPath") %>'
Height="200"
Width="200"
href='<%# Eval("videoId", "PlayVideo.aspx?videoId={0}") %>' />
</ItemTemplate>
</asp:DataList>
On the code behind on page load
public void BindGrid()
{
string strConnString = ConfigurationManager.ConnectionStrings["Dbconnection"].ToString();
using (SqlConnection con = new SqlConnection(strConnString))
{
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandText = "select videoId, videoTitle,thumbPath from videoUpload";
cmd.Connection = con;
con.Open();
DataList1.DataSource = cmd.ExecuteReader();
DataList1.DataBind();
con.Close();
}
}
}
I am facing two issues
- The image is not displaying on ImageButton(or Image control)
- on clicking the imagebutton an error is giving which is given below-
Event validation is enabled using in configuration or <%@ Page EnableEventValidation="true" %> in a page.
For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them.
Its because your thumbpath is wrong.
Not getting into
EnableEventValidation
in this answer becauseImageButton
is not the Control to use here. Change it toOn an unrelated side-note, do not use
u
tag. Its deprecated.