.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Calling a static method in a static class from a base class.

Posted By:      Posted Date: September 22, 2010    Points: 0   Category :ASP.Net

I have the following static class and method:

public static class GenericList


      public static List<DocumentElement> PopulateGenericList()



What is the syntax to call the PopulteGenericList() method from a base class?



View Complete Post

More Related Resource Links

Static Class for Beginners

In general, the members of a class can be accessed by instance of that class when they are in public, but there comes a situation to access or call members of a class without an instance and this can be achieved by declaring them as static

abstract away the source of the connection string using a class with a static property.

ASP.NET provides a configuration system we can use to keep our applications flexible at runtime. In this article we will examine some tips and best practices for using the configuration system for the best results.

The element of a web.config file is a place to store connection strings, server names, file paths, and other miscellaneous settings needed by an application to perform work. The items inside appSettings are items that need to be configurable depending upon the environment, for instance, any database connection strings will change as you move your application from a testing and staging server into production.

Let's abstract away the source of the connection string using a class with a static property.

Cache vs Static Class

Hi All, I am sure this question has been posted many times, but have not got time to wade through. Apologies in advance! I am working on a new web application which has extremely high volumes of traffic, the application uses two large(ish) data tables (approx 15,000 rows/records each - both fairly 'wide' tables....) which are each the result of various JOINS and other intensive operations. The post query operations are unavoidable and the data structure has been optimised wherever possible. I am debating on using the Cache and CacheDependancy classes to store these tables, but fear the 'eviction' process due to the demand in traffic and server resources generally. I can certainly afford to build these tables once, on the first request (near Application Start), but should memory become scarce, do not want the cached data to be recreated during the application lifecycle and have concerns about how ASP.NET will manage demands on this data in such a crisis. For example, if during a period of time, available memory is at an all time low, I would anticipate that the CacheDependancy would keep recreating the tables for each request. (I don't know...) Note: The Cache API is not used elsewhere and the Application and Session scopes are hardly used. At present, I am using just a static class to store the two tables which works a

Working with System.IO.Path static class

Hello everyone. Today, I was exploring the System.IO namespace in .NET 4.0 on an ASP.NET web application where I came to few changes, comparing with the previous versions of .NET, related to the System.IO.Path static class. The Path class contains the same method names in .NET 2.0, 3.5 as well as 4.0, only (in .NET 4.0) new overloads are added to System.IO.Path.Combine() method. In the following blog post, I will show the usage of few methods belonging to the System.IO.Path static class, as well as, the changes in Combine() method added in .NET 4.0. Besides the first method that is available in the previous versions for combining two string paths, now in .NET 4.0 you can combine unlimited strings to the path. Note: For testing purpose, on your web application root, create folders with name Files, Files/SubFolder, Files/SubSubFolder and add three text files: text1.txt (in Files), text2.txt (in Files/SubFolder), text3.txt (in Files/SubFolder/SubSubFolder).   Here are few examples:             string path1 = System.IO.Path.Combine(Server.MapPath("Files"), "text1.txt"); //this will give the path to %WEBAPP_ROOT%/Files/text1.text -             string path2 = System.IO.Path.Combine(Server.MapPath("Files"), "SubFolder", "text2.txt"); //this will give

ASP.NET: Using a static class and methods for the WCF client

Traditionally in our web pages we have instantiated a service client in each page and then called the WCF methods from that instance, adding some caching code to check if the data exists and if not, make the WCF call and cache the data for the next time. As our site grows we find we're repeating this same pattern and are looking to move it all to a single class. Can we make that class static, with a single static instance of the WCF client, and static methods, safely? // pseudo-code // assume WcfDataService has a GetFoo(int i) method public static class WcfMethods { public static WcfDataService client = new WcfDataService("connectionType"); public static DataSet GetFoo(int i) { if (Cache["foo" + i] == null) { Cache.Insert("foo" + i, client.GetFoo(i)); } return Cache["foo" + i] as DataSet; } } Then in our pages we can just call WcfMethods.GetFoo(x) directly.  Figure we have 100 users visiting our various pages simultaneously.  Will this cause contention issues?  Like I mentioned, up till now we've not used static instances.  It's not caused any problems, but we're just looking to refactor.  I realize we could also use the above pseudo-code pattern using an instance class and methods instead static ones. I haven't dealt with threading or synchro

Sharing of Non-Static member variables of a class using .NET Remoting

This kind of weird. I am trying to host an object of a class X (a class library class). This is a SAO and I have set the WellKnownMode as Singleton in the server configuration. <wellknown mode="Singleton" When multiple clients fetch the instance of the class X they can share the static member variables. Any changes made to the static variables are visible to each other. The problem is with the non-static member variables of the class. Each instance is having a local copy of the non-static variables. Why should that happen in case of a Singleton mode? Am I missing something for which this is happening? Any help will be appreciated.  A for apple, B for boy, C for c++

Calling a method with a class object as parameter data type.

   [WebMethod]    public string GetInfo(Customer inCust)    {        // Code in here    } I have a web service that resides on a remote server. I want to call a public method of theweb service named  "GetInfo". The method is shown above. The web service method expects a class object oftype "Customer". What I did to create a Customer object was to define in my asp.net project my own class named "Customer" which is exactlythe same as the class that belongs to the web service project on the remote server. I then created an instance of Customerand tried to call the web service passing in an object of type customer : my.Service ws = new my.Service(); // Get web service connectionCustomer aCustomer = new Customer();aCustomer.Initialize();ws.GetInfo(aCustomer) // call web service passing in a Customer object The problem is that the compiler gives me the following error: Value of type '_Default.Customer' cannot be converted to 'ws.Class1'. Here Default is refering to my Default.aspx.cs code. Why is this? Do I need to Cast my "aCustomer" class object to a type ofws.Customer ? How do I do that?

Is it possible to add a class method to CLR base class like Date?

Hi All, I would like to add a class method like ParseYYYYMMDD to the Date base class. So that I can use the following code. Dim result As Date = Date.ParseYYYYMMDD(dateString) Any idea? Is it possible via extension? Thanks! Regards, AlexAlex Lau from HKSAR

how to jquery call a other call function other class is not static

how to jquery call a other call function other class is not static[WebMethod]    public static bool Verify(string username, string password)    {        //Do your logic with username, password  here        //I am just checking with admin/admin credentials            Console.WriteLine("Ritu");        string s="SELECT p.RETMSG FROM P_DOCSHARE(1001,1453,'1002,1012,1011','Add') P";                 CCUtility c;                c=new CCUtility();             c.JavascriptMessage(c.Insert_P(s));        return (username == "admin" && password == "admin");    }

WPF OneWay ItemsSource Binding to a static class's dictionary?



I have a global Static class which implements a dictionary of languages:

namespace Tools.DataAccess
  static public class Planner
    static public class Dictionaries
      static public Dictionary<UInt32, string> Languages { get; }

I am trying to bind a ComboBox's ItemSource to the static dictionary called "Languages". It works very well through code-behind at the moment:

ui_languages_cmo.ItemsSource = Tools.DataAccess.Planner.Dictionaries.Languages;

However I cannot bind it through XAML. The dictionary actually resides in a separate namespace (Tools) than my UserControl (myApp). Here's roughly what I'm trying to do:

<UserControl x:Class

What scenarios make us to create static class and static methods?



I am aware of the terminology "Static Member", "Static Class" and "Static Method"

Give some examples, What scenarios make us to use or create Static member, Static Class and Static Method?

How to add item into List<> in static Class


Hi, as above. Here the code.


1)Note :  Pictures is a collection of picture, PicNames is collection of names of pictures.

     MediaLibrary ml = new MediaLibrary();

            var ChkPics = ml.Pictures;
            var PicNames = from p in ChkPics
                           where p.Name.Contains("s")
                           select p;


2) Static Class

public static class PhotoNames
        private static List<string> m_Photoname = new List<string>();

        public static List<string> PhotoFileNames

lifespan of a property inside a static class in IIS



I want to know , how good / bad is it to save configuration values in a static properties?

I am creating an application which reads configuration from an XML file and a DataContext file, instead of sending the CustomConfig class into the configuration.xml each time I tought about using an ReadXml() method on application_start at the global.ascx

the ReadXml() method would save the data in static properties of CustomConfig and whereever I would want to read that particler data I would ask CustomConfig.PROERTY_NAME

My question is ? how smart it is ? how long does IIS would save the data in a static member? (if as long as the application exists then I'm ok as long as I add the ReadXml() in the application_start)

would like to hear your comment.. 

Application variable or static class for global string?


I need to keep a global variable throughout the whole time the user is at my site, but do I use Application or a static class? The string variable should store a region name and my site makes a few changes depending on which region that has been set.

I read that Application was mainly for classic ASP, but I also read that a static class cannot be instantiated at runtime (e.g. when the user has logged in).

So, have I got something wrong here and which solution do I use?



How to change the default page base class?


I've tried setting the <pages pageBaseType="DynamicWebPage" /> value in web.config, but when I response.write out the page type, I'm still getting Microsoft.WebPages.WebPage.

I'm simply trying to sub-class WebPage and add some additional functionality such as a dynamic PageData dictionary similar to Phil Haack's dynamic ViewData dictionary.



Can I replace the EntityObject as base-class in Entity Designer 3.5 sp1?


I'm using EF3.5sp1 for a project, and I've been working around many of its problems... as such, my entity partial classes have a lot of logic in them for change-tracking and whatnot.  Obviously, I'd like to factor this logic out into a common base class, but of course all my objects must derive from EntityObject.  Is it possible to tell them to derive from some class of my own invention (which would actually likely derive from EntityObject themselves)?

I'd rather avoid editing the EDMX file unless the changes will be safe on entity-model-update, since I'm still making changes to the database schema in this early state of my project.


Also, is there any good workaround for the fact that the change isn't tracked when you change EntityReference.EntityKey?

CLR Inside Out: What's New in the .NET Framework 4 Base Class Library


Just about everyone who uses Microsoft .NET uses the Base Class Libraries (BCL).When we make the BCL better, almost every managed developer benefits. This column will focus on the new additions to the BCL in .NET 4 beta 1.

Justin Van Patten

MSDN Magazine September 2009

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend