5
I have a class where I have saved a configuration key being key and value, but I need to take the value of this key and move to my page cshtml
. I’m having a hard time with this.
I have already passed the class path, but I can not reference to bring the value of the key. I need to bring and value the key so I can make a simple logic upon that value.
I have a key configuration class that is saved: (key is Reportserver)
public static string ReportServer
{
get { return InstanceResolverFor<IConfigurationSource>.Instance.Read("ReportServer"); }
}
I have my page cshtml
where you have this Razor syntax:
@section scripts{
@Scripts.Render("~/Content/js/app/FIDC/index.js")
@if (Model != null)
{
if (Model.Erro)
{
<script>
modal.exibir("Ops", "@Model.MensagemErro", modal.tipoModal.Erro);
</script>
}
else
{
<script>
modal.exibir("Ok", "@Model.MensagemSucesso", modal.tipoModal.Sucesso);
</script>
}
}
}
Got My Business Class: (I’m taking the value of my key through the config.ReportServer
)
var serverReport = reportViewer.ServerReport;
serverReport.ReportServerUrl = new Uri("http://CCD-APPBI-001:80/ReportServer");
serverReport.ReportPath = string.Concat("/", config.ReportServer, "/",relatorio);
Now I need to get the value of this key ReportServer
for my html, where I have two tags below:
<a target="_blank" href="http://ccd-appbi-001/Reports/Pages/Report.aspx?ItemPath=%2fRelatoriosClientes%2fcessao_polo&SelectedSubTabId=GenericPropertiesTab&SelectedTabId=ViewTab;rs:Command=Render">Abrir</a>
<a target="_blank" href="http://ccd-appbi-001/Reports/Pages/Report.aspx?ItemPath=%2fRelatoriosClientes%2fsabemi&SelectedSubTabId=ReportDataSourcePropertiesTab&SelectedTabId=ViewTab">Abrir</a>
If anyone can help, thank you.
Thanks Miguel, however my problem is that the key already has a value that is saved in a bank nosql that lives within my application, Summarizing: in Homologation the key will point reports to homologation and Production the key will point report to production.
– Renan Carvalho
So. You plug into the no-sql database, load the key into the variable
chave
and passes it to the cshtml view the way I indicated.– Miguel Angelo
Usually all the logic of doing database queries is in the controller, exactly so that the view is just a simple layer of visualization.
– Miguel Angelo
I’ve changed my mind. I’ll answer, because the question now is completely different.
– Leonel Sanches da Silva