Skip to main content

Posts

Method Overriding with C#

Method overriding is a feature that allows you to invoke functions (that have the same signatures) that belong to different classes in the same hierarchy of inheritance. Let's understand method overriding using few examples. Output Above code consists of base class A and a derived class B. Class A consists of method Show(). Class B hides the function Show() it inherited from the base class A by providing its on implementation of Show(). In the above code we first created object of type A. Using the reference variable “a” we invoke the function Show(). As expected,  Show() of class A is executed because the reference variable “a” refers to the object of class A. Then we created an object of Derived class B and storing its reference in the reference variable “a” of type A. Using the reference variable “a” we invoke the function Show(). Since “a” contains a reference to an object of type B we would expect the function Show() of class B to get executed. But that do...

Make sure "AjaxControlToolkit.Properties.Resources.NET4.resources" was correctly embedded or linked

Error Message Could not find any resources appropriate for the specified culture or the neutral culture.  Make sure "AjaxControlToolkit.Properties.Resources.NET4.resources" was correctly embedded or linked into assembly "AjaxControlToolkit" at compile time, or that all the satellite assemblies required are loadable and fully signed. Reason AjaxControlToolkit’s control load reference refers to the base System.Web.UI.Control method which is present as a part of the ASP.NET AJAX Libraries and those libraries are referenced only when the ScriptManager is referenced in the page. Solution Add ScriptManager in the page

Validating DropDownList using RequiredFieldValidator

In ASP.NET we need to validate DropDownList controls. But validating the DropDownList control with RequiredFieldValidator is not a straight forward as validating a TextBox control with RequiredFieldValidator. It requires little extra work. Following are the steps for validating a  DropDownList  with  RequiredFieldValidator Step 1: Create a DropDownList control 1: < asp:DropDownList ID ="ddlFruit" runat ="server" Height ="22px" Width ="200px" > 2: < asp:ListItem > - Select - </ asp:ListItem > 3: < asp:ListItem > Apple </ asp:ListItem > 4: < asp:ListItem > Orange </ asp:ListItem > 5: < asp:ListItem > Banana </ asp:ListItem > 6: < asp:ListItem > Pineapple </ asp:ListItem > 7: </ asp:DropDownList > Step 2: Add a RequiredFieldValidator 1: < asp:RequiredFieldValidator ID ="rfvFruit" runat =...

Get the BIOS Serial Number with C#

Fisrt you have to import the following referenece in to your project. System.Management Sample Code 1: using System; 2: using System.Management; 3: using System.Windows.Forms; 4:   5: namespace DemoProjects 6: { 7: public partial class frmBIOSSerial : Form 8: { 9: public frmBIOSSerial() 10: { 11: InitializeComponent(); 12: } 13:   14: private void btnGet_Click( object sender, EventArgs e) 15: { 16: string serialNumber = string .Empty; 17:   18: ManagementObjectSearcher MOS = new ManagementObjectSearcher( " Select * From Win32_BIOS " ); 19: foreach (ManagementObject getserial in MOS.Get()) 20: { 21: serialNumber = getserial[ "SerialNumber" ].ToString(); 22: } 23:   24: lblSerialNumber.Text = serial...

Implement Google Analytics when using Dynamic Views on Blogger

Google Analytics is the best service to track your web site's stats. I have been using Google Analytics for about 3 years now. It has all the stats about my websites that I can think of. Google Analytics provide JavaScript code which you have to put in your <head> tag to start tracking the stats for your site. But when using the new Dynamic Views template, we can’t edit the template to insert our tracking codes, because in Dynamic Views templates user aren't allowed to edit HTML, so that's nearly impossible to implement the JavaScript into your template. But yet there's a way to implement Google Analytics on your Blogger having Dynamic Views, the option is in Blogger' Settings, hidden somewhere. Let's take a look at what we will do to succeed it. Follow the steps After adding your site to Google Analytics, you will get the tracking Id on the Screen. Once you have copied your tracking id, head back to Blogger Dashboard & Go th...