Starting in 2019, the Reporting control is no longer included in Essential Studio®. If you're experiencing issues with the Syncfusion� Reporting Platform, Report Viewer, Report Designer, or Report Writer, we recommend migrating to Bold Reports, our dedicated reporting platform.

Bold Reports offers a comprehensive suite of tools and features for all your reporting needs, and we will help you make a smooth transition from the discontinued control. Our support team at https://support.boldreports.com/ is here to assist you with any questions or difficulties you may encounter during the migration process.

We thank you for choosing Syncfusion� and appreciate your understanding.

Trying to find a way to parameterize a report name to change in a compiled app

Greetings,


I have an app that renders SSRS reports for the internet users, secured by Azure authentication tokens. The asp.net page has the report names hardcoded in its .cs file, not accessible after compiling the app.

I have been searching for ways to define a variable somewhere in a view that is editable from IIS (_ViewStart), for instance, assign a value to it and use it in the .aspx page on runtime

Something like:

The variable in _ViewStart view:

@{

    public static string report = "reportname";

}

must be available in the .cs file below (in bold):

ssrs_report.aspx

   ssrs_report.aspx.cs


Any ideas are appreciated. I'd like to avoid recompiling the app every time developers want to point it to a different report








6 Replies 1 reply marked as answer

MR Manoranjan Rajendran Syncfusion Team November 30, 2021 02:32 PM UTC

Hi Polaro, 
 
Thanks for contacting Bold Reports support. 
 
We have validated the your requirement. Using setmodel we can change the report path dynamically in the report viewer. We have attached the sample for this. Could you please check and share the details. If provide sample was not your requirement. Could you please share your requirement with additional details with snap. Its helpful for our further validation. 
 
 
Sample details : 
Change the Report path dynamically in Report viewer using setmodel.  
Index.cshtml 
 
    function ChangeReport() { 
 
        var reportObj = $("#viewer").data('boldReportViewer'); 
                reportObj.setModel({ 
                    reportPath: $("#ReportPath").val(), 
                }); 
 
    } 
 
Reports are in Resource folder. 
 
 
Regards, 
Manoranjan R 



PO polaro November 30, 2021 03:15 PM UTC

Thanks Manoranjan, for the great suggestion,


I am having trouble downloading all the required libraries for some reason. It could be our corporate network, will try it at home.


From what I see, you have a button on the site that controls the variable. All I need is to open the Index page in Notepad from IIS, change the repotname variables and click Save. The change should repoint the reportviewer to render a different SSRS report.


I just need something for an administrator to control, not a user. The variable should be visible within the code only






PO polaro December 1, 2021 02:30 PM UTC

Greetings, 


I have managed to solve it by utilizing the hiddenfield control.


In every .aspx file, add the line, specifying the HiddenFieldID (a string) and report path in "Value":


<asp:HiddenField ID="reportid" Value="/Reports/reportname" runat="server"></asp:HiddenField>


In respective aspx.cs file, reference the hidden field's value as:


string reportname = Convert.ToString(reportid.Value)


Now, after compiling the app and deploying it to IIS, I can change the Value without recompiling





Marked as answer

MR Manoranjan Rajendran Syncfusion Team December 2, 2021 03:37 AM UTC

Hi Polaro,


Thanks for the update. 


If you have any other queries. Please create a new ticket from the below site. We were always happy to assist you. 

https://support.boldreports.com/ 


Regards, 

Manoranjan R 



CT CodeStore Technologies May 17, 2023 06:25 AM UTC

Hii

To avoid hardcoding report names and allow for dynamic configuration without recompiling the app, you can consider using a configuration file or a database to store the report names. Here's an approach you can take:


Create a configuration file or a database table to store the report names. This will allow developers or administrators to modify the report name without touching the code.


In your ASP.NET application, retrieve the report name from the configuration file or the database during runtime. You can use a configuration provider or a database connection to fetch the value.


Assign the retrieved report name to a variable or property in your ASP.NET application, which can then be accessed in your .aspx page and .cs file.


For example, using a configuration file approach:


Create a configuration file, such as appsettings.json, with the report name:

json

Copy code

{

  "ReportSettings": {

    "ReportName": "reportname"

  }

}

In your ASP.NET application, add the configuration file and configure the app to read from it during startup:

csharp

Copy code

// In your Startup.cs file or similar

public void ConfigureServices(IServiceCollection services)

{

    // Other configurations...


    // Add configuration file support

    services.Configure<ReportSettings>(Configuration.GetSection("ReportSettings"));

}

Create a class to represent the report settings, which will be used to retrieve the report name:

csharp

Copy code

public class ReportSettings

{

    public string ReportName { get; set; }

}

In your ASPX code-behind file (ssrs_report.aspx.cs), access the report name using the injected configuration:

csharp

Copy code

using Microsoft.Extensions.Options;


public partial class ssrs_report : System.Web.UI.Page

{

    private readonly ReportSettings _reportSettings;


    public ssrs_report(IOptions<ReportSettings> reportSettings)

    {

        _reportSettings = reportSettings.Value;

    }


    protected void Page_Load(object sender, EventArgs e)

    {

        // Access the report name

        string reportName = _reportSettings.ReportName;


        // Other logic...

    }

}

By utilizing a configuration file or a database, you can modify the report name without recompiling the application. Developers or administrators can update the configuration, and the application will dynamically pick up the changes during runtime.

If you want to hire professional azure  developers you can visit our websitehttps://codestoresolutions.com/hire-azure-developer/



AM Arumugasami Murugesan Syncfusion Team May 18, 2023 10:18 AM UTC

Dear Customer,


Thanks for the suggestion.


If you have any other queries. Please create a new ticket using your account using the below link. We are always happy to assist you.

https://support.boldreports.com/support/tickets


Regards,

Arumugasami M


Loader.
Up arrow icon