Banner Ad

Tuesday, February 4, 2014

Daily Interview Question #6: What are the different types of Constructor in C#?

By Francis   Posted at   1:03 PM   C# Interview Questions No comments

Below is the list of Constructors available in C#:

1. Default Constructor

2. Parameterized constructor

3. Static Constructor.


By default constructor have “public” as access specifier. A class can have more than one Constructor. In C# “this” keyword is used to access the constructor from another constructor. By default, C# will provide a default constructor if no constructor declared.


Hope this helps!

Monday, February 3, 2014

Attach Javascript to Button

By Francis   Posted at   2:01 PM   No comments

In this tutorial I’m going to explain how to add a javascript snippet to the ASP.Net server side Button Control.



Copy the below code in an .aspx file:


<html xmlns="">
<head runat="server">
<form id="form1" runat="server">
<asp:Button runat="server" ID="btnSubmit" Text="Click Me" />


Copy the below code in an .aspx.vb file:

 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
btnSubmit.Attributes.Add("onclick", "alert('Button Clicked');return false;")
End Sub


The above code add “onclick” attribute to the Server side button “btnSubmit”. The attribute value is just a javascript snippet, which just show an alert box.


Take a look, after the alert we specify the “return  false;” which avoid the webform to be refreshed.


Hope this helps!

Connect with Us