Using AppSettings values

4 posts, 1 answers
  1. Andy Green
    Andy Green avatar
    342 posts
    Member since:
    Aug 2008

    Posted 30 Jan 2011 Link to this post

    Is there a way to use values from the main web app settings file.

    I have a web and separate class files for the reporting, the web imports the reporting class.

    I want to dynamicly change the logo on a report base on the value in the web appsettings.

    This is how I would do it in the web:



    .imgLogo.Value = ConfigurationManager.AppSettings("TrustLogo")

    But this currently doesn't work from the reporting class.



  2. Answer
    Peter avatar
    1611 posts

    Posted 02 Feb 2011 Link to this post

    Hello Andy Green,

    Telerik Reporting is a standard .NET class and you can easily access the AppSettings within an User Function to retrieve an Image and set the PictureBox.Value with Binding to GetImage(). Check out the following code snippet:

    Public Shared Function GetImage() As Image
        Dim filename As String = ConfigurationManager.AppSettings("TrustLogo")
        Return Bitmap.FromFile(filename)
    End Function

    Best wishes,
    the Telerik team
    Get started with Telerik Reporting with numerous videos and detailed documentation.
  3. DevCraft banner
  4. John
    John avatar
    4 posts
    Member since:
    Feb 2011

    Posted 10 Mar 2011 Link to this post

    I have a similar problem and cannot get it to work in the Silverlight Reporting. I have added the following into my Reports class library app.config file

        <add key="MyKey" value="MyValue"/>

    I then created a user function with the following code

    public static string GetAppSettingValue()
        string returnValue = "";
            returnValue = ConfigurationManager.AppSettings["MyKey"].ToString();
        catch (Exception ex) { returnValue = ex.Message; }

        return returnValue;

    I then tested it in a report by returning the value of my user function to a textbox but all I get is the error "Object Reference not set to an instance of an object"

    Can you show me an example of reports retrieving the value from the config file?


  5. Andy Green
    Andy Green avatar
    342 posts
    Member since:
    Aug 2008

    Posted 10 Mar 2011 Link to this post

    This is what I have.

    Using best practice I have a separate project for my reports. In the code behind for the report I have


    Public Sub New()






    Me.imgLogo.Value = ConfigurationManager.AppSettings("Logo")




    End Sub

    Where imgLogo is the image control on y report



Back to Top