I have a file path from a database (~/Dashboard/YearbookRepository/SY2122A/SY 2019-2020.pdf). I bind it in the DataList control using a hyperlink control.
How can I call the hyperlink from code behind using a button?
Below is my aspx file
Below is my code behind
protected void btnSelect_Click(object sender, EventArgs e)
{
DataListItem item = (DataListItem)(sender as Button).NamingContainer;
HyperLink hlYearbook = item.FindControl("hlYearbook") as HyperLink;
string url = hlYearbook.Text;
hlYearbook.NavigateUrl = url;
hlYearbook.Target = "_blank";
}
If I click the button, the hyperlink does not work. Thank you in advance.

Rijwan AnsariPosted Feb 21, 2022, 3:19 PM
Sachin SinghPosted Feb 21, 2022, 4:53 AM
Jes SiePosted Feb 21, 2022, 3:19 AM
Sachin SinghPosted Feb 15, 2022, 9:34 AM