Friday, 5 September 2014

How to call a base class method even derived class object is created.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace InheritenceExample
{
class Program
{
static void Main(string[] args)
{
b obja = new b();
obja.Method1();
Console.ReadLine();
}
}


public class a
{
public virtual void Method1()
{
Console.WriteLine("base class method is called.");
}
}

public class b : a
{
public override void Method1()
{
base.Method1(); // calling base class method.
}
}

}
Result :  Base class method is called.

Interview Quations


Q1. Can we access the static webservice method by using Json ?

ANS. No

Q2. How to bind dropdownlist using  each function in jquery ?

ANS.    

                      <select id="ddlProducts"> </select> //html control
// jquery
            $("#ddlProducts").append($('<option>').text('select').attr('value', 0));
            $.each(data.d, function (i, item) {
            $('#ddlProducts').append($('<option>').text(item.ProductName).attr('value', item.ProductID));

Monday, 28 July 2014

What is MVC ?

Inter View Questions on MVC

what is MVC?

MVC stands for Modal View Controller.  MVC is a design pattern which using using for developing an application.

What is Design Pattern?

Design Pattern is a pre-Defined solution for a problem which is occurred in the application.

Note : MVC comes under architectural design pattern category. 

Thursday, 3 July 2014

Googe charts

 <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">



     
        google.load('visualization', '1.0', { 'packages': ['corechart'] });      
        google.setOnLoadCallback(drawChart);
        function drawChart() {
         
            $.ajax({
                type: "POST",
                contentType: "application/json; charset=utf-8",
                url: "webservice.asmx/test",
                data: "{'test':'test1'}",
                dataType: "json",
                success: function (response) {
                    drawVisualization(response.d);
                },
                error: function (response) {
                    alert("Error accured while updating item Status.");
                }
            });

        }

        function drawVisualization(dataValues) {        
            var data = new google.visualization.DataTable();
            data.addColumn('string', 'CustomerName');
            data.addColumn('number', 'POHeaderID');
            for (var i = 0; i < dataValues.length; i++) {            
                data.addRow([dataValues[i].CustomerName, dataValues[i].POHeaderID]);
            }        
            var options = { 'title': 'PO List',
                'width': 400,
                'height': 300
            };

            // Instantiate and draw our chart, passing in some options.
            var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
            chart.draw(data, options);
        }
    </script>

What is Dot Net Framework

1. What is dot net framework?

2. How compilation works in .net ?

3. What is IL Code?

4. Different parts of .net frame work ?

· What is dot net frame work?

Dot net frame work is a platform which contains some libraries, some utilities, some compilers L+U+G which we can use developing , building and deploying varies dot net applications, web applications, windows applications, WCF applications, WPF applications

· How compilation works in dot net?

Compilation works in dot net works in two stages

ü Normal dot net code(C#,VB.Net) converted into IL(Intermediate language) by using compilers.

C# converted into IL by using CSC(c# compiler)

VB.net converted into IL by using VBC (VB compiler)

(IL is the half compiled code and IL is same for all the languages)

C# code = IL Code = VB code

ü IL con be taken by CLR (Common Language Runtime) and passed to JIT(Just In Compiler)

JIT is the responsible for convert the IL code to machine code.

· What is IL?

IL is nothing but a half compiled code(MSIL Microsoft Intermediate language)

JIT will get the control over the IL Code by sing CLR.

This JIT converted the Compiled code (IL) to machine code which is can be understand by operating system(machine code).

· Different parts of .Net framework.

clip_image001[4]

CLR Responsibilities

§ Converted IL Code into machine Code

§ Garbage collection.

§ Thread management.

§ Security (Code Access Security CAS).

CLR Consists of CTS, CTS Consists of CLS(Common language specification)

clip_image002[4]CTS CLS

CLS is defines set of rules which is must followed by all the dot net compiled languages

Tuesday, 29 April 2014

How to disable the mouse right click


<script language="JavaScript" type="text/javascript">
        //Message to display whenever right click on website
        document.onmousedown = disableclick;

        status = "Right click option is not allowed";

        function disableclick(e) {
            if (event.button == 2) {
                alert(status);
                return false;
            }
        }
   
    </script>

Wednesday, 19 February 2014

How to Generate sample Excel file in C#

ASP.Net

<body>
    <form id="form1" runat="server">
    <div>
    <asp:Button runat="server" ID="btnExcel" Text="Generate Excel" OnClick="btnExcel_Click" />
    </div>
    </form>
</body>



Backend Code:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Reflection;
using Microsoft.Office.Interop.Excel;

namespace Excelgeneration
{
    public partial class ExcelGeneration : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnExcel_Click(object sender, EventArgs e)
        {
            GenerateExcel();
        }

        #region GenerateExcel
        public void GenerateExcel()
        {
            Application oXL = new Application();
            Workbook WB = null;
            Worksheet WS = null;
            Range oRng;

            oXL.Visible = true;
            // creating workbook
            //--------------------
            WB = (Workbook)(oXL.Workbooks.Add(Missing.Value));

            //Create work sheet
            WS = (Worksheet)(WB.ActiveSheet);

            //save the Excel File
            // -----------------------
            WB.SaveAs(@"D:\Excelfiles\Srinivas5", XlFileFormat.xlWorkbookDefault);

            // F:\Desktop is the file path
            // srinivas is the file name  

            //oXL.UserControl = true;


        }
        #endregion
    }
}