1

URL の Web.Release.config と Web.Debug.config で定義されたキーと値のペアがあります。C# ファイルでは、次のように使用します (キーは "Report-URL" です)。

string reportUrl = System.Configuration.ConfigurationManager.AppSettings["Report-URL"];
CoverSheetReportViewer.ServerReport.ReportServerUrl = new Uri(reportUrl);

これは機能しますが、現在 URL がハードコードされている .ascx ファイルで使用したいと考えています。

<asp:HyperLink ID="HyperLinkReports" runat="server" CssClass="LeftNav" 
NavigateUrl="http://mygroup-dev-appsr/ReportServer?%2fASD%2fTransactions%2fCoverSheet&rs:Command=ListChildren" />

どうすればいいですか?

4

1 に答える 1

3

インライン構文の助けを借りてこれを試してください

NavigateUrl="<%$ AppSettings:Report-URL %>

また

.ascx で

<a href="<%# this.GetReportUrl() %>">Report</a>

.ascx.cs で

protected string GetReportUrl(){
 string reportUrl = System.Configuration.ConfigurationManager
                   .AppSettings["Report-URL"]; 

 return  new Uri(reportUrl).ToString();
}

別の構文リファレンス

于 2013-10-04T15:38:42.657 に答える