Last post Aug 30, 2020 01:40 PM by KathyW
Aug 30, 2020 07:01 AM|uid384379|LINK
I have a HyperLink like below:
<asp: HyperLink runat="server" ID="PdfHyperLink" Target="_blank" NavigateUrl='<%# (Eval("FilePath")) %>' />
Upon Clicking on HyperLink, I need to show Pdf file in a new window and, this file is coming from FilePath on Code Behind.
protected void btn_Click (object sender, EventArgs e)
Entities.Masters.Country country = new Entities.Masters.Country();
country.Id = Convert.ToInt32(CountryIdHiddenField.Value);
Country_Bal countryBal = new Country_Bal();
String FilePath = countryBal.GetCountriesPdf(country); PdfHyperLink.NavigateUrl = FilePath;
I'm getting the file name in .pdf format on FilePath upon debugging. but HyperLink is not binding to this FilePath of btn_Click method to show pdf file in a new window.
I have many cases in Business Access Layer like below, I'm getting the intended FilePath on Code Behind method, upon the selected country, and this selected country pdf file should be shown on the new window. But unable to bind the HyperLink to CodeBehind
to Choose FilePath.
public string GetCountriesPdf(Entities.Masters.Country country)
string FilePath = ConfigurationManager.AppSettings["GetCountriesPdf"];
return FilePath+= "Country file"+".pdf";
Aug 30, 2020 01:40 PM|KathyW|LINK
If you are setting the hyperlink NavigateURL in code behind, remove the
NavigateUrl='<%# (Eval("FilePath")) %>'
from the HyperLink code in the page.
It's not clear what your btn_Click code is attached to, so I can't comment further.