Tuesday, December 18, 2012

What is view state and use of it? The current property settings of an ASP.NET page and those of any ASP.NET server controls contained within the page. ASP.NET can detect when a form is requested for the first time versus when the form is posted (sent to the server), which allows you to program accordingly.

What are user controls and custom controls? 
Custom controls: 
A control authored by a user or a third-party software vendor that does not belong to the .NET Framework class library. This is a generic term that includes user controls. A custom server control is used in Web Forms (ASP.NET pages). A custom client control is used in Windows Forms applications.

User Controls: 
In ASP.NET: A user-authored server control that enables an ASP.NET page to be re-used as a server control. An ASP.NET user control is authored declaratively and persisted as a text file with an ascx extension. The ASP.NET page framework compiles a user control on the fly to a class that derives from the System.Web.UI.UserControl class.

What are the validation controls? 
A set of server controls included with ASP.NET that test user input in HTML and Web server controls for programmer-defined requirements. Validation controls perform input checking in server code. If the user is working with a browser that supports DHTML, the validation controls can also perform validation using client script.

What's a bubbled event? When you have a complex control, like DataGrid, writing an event processing routine for each object (cell, button, row, etc.) is quite tedious. The controls can bubble up their eventhandlers, allowing the main DataGrid event handler to take care of its constituents. Suppose you want a certain ASP.NET function executed on MouseOver over a certain button.

Where do you add an event handler? 
It's the Attributesproperty, the Add function inside that property.
e.g. btnSubmit.Attributes.Add("onMouseOver","someClientCode();") 
Some Dot Net Interview Questions and Answers ::

What are the basic concepts of object oriented programming?


It is necessary to understand some of the concepts used extensively in object oriented programming.These include
§         Objects
§         Classes
§         Data abstraction and encapsulation
§         Inheritance
§         Polymorphism
§         Dynamic Binding
Message passing.


Can you inherit multiple interfaces?
Yes. Multiple interfaces may be inherited in C#.

What is the difference between public, static and void?

§        public :The keyword public is an access modifier that tells the C# compiler that the Main method is accessible by anyone.
§         static :The keyword static declares that the Main method is a global one and can be called without creating an instance of the class. The compiler stores the address of the method as the entry point and uses this information to begin execution before any objects are created.
void : The keyword void is a type modifier that states that the Main method does not return any value.

What are the types of access modifiers in C#?

Access modifiers in C# are :
 public
§        protect
§        private
§        internal
internal protect

What is boxing and unboxing?
Implicit conversion of value type to reference type of a variable is known as BOXING, for example integer to object type conversion.
Conversion of reference type variable back to value type is called as UnBoxing.

Where are the types of arrays in C#?
§         Single-Dimensional
§         Multidimensional
Jagged arrays.

What is the difference between Object and Instance?
An instance of a user-defined type is called an object. We can instantiate many objects from one class.
An object is an instance of a class.

Define destuctors?
A destructor is called for a class object when that object passes out of scope or is explicitly deleted.A destructors as the name implies is used to destroy the objects that have been created by a constructors.Like a constructor , the destructor is a member function whose name is the same as the class name but is precided by a tilde.

Friday, November 9, 2012

How to over come this exception...

Unable To Evaluate Expression Because Code Is Optimized Or Native Frame Is On Top Of Stack

Just do this..

catch (System.Threading.ThreadAbortException)
{

}

Show Data in combobox like a Grid

public void ShowComboBox()
        {
            try
            {
                SqlConnection con = new SqlConnection("Data Source=ANONYMOUS;Initial Catalog=ABC;Integrated Security=True");
                con.Open();
                SqlCommand cmd = new SqlCommand("select * from employee_test", con);
                DataTable dt = new DataTable();
                cmd.CommandType = CommandType.Text;
                cmd.ExecuteNonQuery();
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                da.Fill(dt);
                comboBox1.DataSource = dt;
               
                comboBox1.DisplayMember = "emp_id";

                comboBox1.ValueMember = "emp_id";
                comboBox1.DrawMode = DrawMode.OwnerDrawFixed;
                comboBox1.DrawItem += delegate(object cmb, DrawItemEventArgs args)
                {
                    args.DrawBackground();
                    DataRowView drv = (DataRowView)comboBox1.Items[args.Index];

                    // Retrieve the value of each column.
                    string id = drv["emp_id"].ToString();
                    string name = drv["emp_name"].ToString();
                    string salary = drv["emp_salary"].ToString();
                   
                    // Get the bounds for the first column
                   
                    Rectangle r1 = args.Bounds;
                    r1.Width /= 3;

                    // Draw the text on the first column
                    using (SolidBrush sb = new SolidBrush(args.ForeColor))
                    {
                        args.Graphics.DrawString(id, args.Font, sb, r1);
                    }

                    // Draw a line to isolate the columns
                    using (Pen p = new Pen(Color.DarkBlue))
                    {
                        args.Graphics.DrawLine(p, r1.Right, 0, r1.Right, r1.Bottom);
                    }

                    // Get the bounds for the second column
                    Rectangle r2 = args.Bounds;
                    r2.X = args.Bounds.Width / 3;

                    r2.Width /= 2;

                    // Draw the text on the second column
                    using (SolidBrush sb = new SolidBrush(args.ForeColor))
                    {
                        args.Graphics.DrawString(name, args.Font, sb, r2);
                    }
                    using (Pen p = new Pen(Color.DarkBlue))
                    {
                        args.Graphics.DrawLine(p, r2.Right, 0, r2.Right, r2.Bottom);
                        //args.Graphics.DrawLine(p, r2.Left,0, r2.Left, r2.Bottom);
                    }


                    Rectangle r3 = args.Bounds;
                    r3.X = (args.Bounds.Width * 2) / 3;
                    r3.Width = (r3.Width) / 2;

                    // Draw the text on the first column
                    using (SolidBrush sb = new SolidBrush(args.ForeColor))
                    {
                        args.Graphics.DrawString(salary, args.Font, sb, r3);
                    }

                };

            }
            catch (Exception ex)
            {
                MessageBox.Show("Error : " + ex);
            }
        }

Friday, September 28, 2012

test


DropDownList1.DataSource = ds;
DropDownList1.DataValueField = "id";
DropDownList1.DataTextField = "username";
DropDownList1.Items.Clear();
DropDownList1.Items.Insert(0, new ListItem("Select", "Select"));
DropDownList1.DataBind();


GridView1.DataKeys[e.RowIndex][0].ToString();


 protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
    {
        GridView1.EditIndex = e.NewEditIndex;
        BindGrid();
    }


protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
    {
        GridView1.EditIndex = -1;
        BindGrid();
    }


if (con != null)
            {
                con.Close();
            }
            if (cmd != null)
            {
                cmd.Dispose();
            }




Friday, September 21, 2012


Insert      

string scon = "Data Source=MAYANKSHARMA-PC;Initial Catalog=aman;Persist Security       Info=True;User ID=sa;password=getsetgo";
        con = new SqlConnection(scon);
        cmd = new SqlCommand("",con);
        con.Open();
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.Add("",SqlDbType.VarChar,50).Value = TextBox1.Text.Trim();
        cmd.Parameters.Add("",SqlDbType.VarChar,50).Value = TextBox2.Text.Trim();
        cmd.ExecuteNonQuery();

Fetch


string connec = "Data Source=MAYANKSHARMA-PC;Initial Catalog=aman;Persist Security Info=True;User ID=sa;password=getsetgo";
        con = new SqlConnection(connec);
        cmd = new SqlCommand("",con);
        con.Open();
        cmd.CommandType = CommandType.StoredProcedure;
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataSet ds = new DataSet();
        da.Fill(ds);
        GridView1.DataSource = ds;
        GridView1.DataBind();

Thursday, April 21, 2011

Dinamic SEO

/***********Page Title **********************************************************
Page.Title = dr["Book_name"].ToString();
//*********************************************************************

void _HtmlMetaTags()
{
HtmlMeta myMetaKeyWords = new HtmlMeta();
HtmlMeta myMetaDescription = new HtmlMeta();
HtmlMeta myMetaRobot = new HtmlMeta();
HtmlMeta HTTP_EQUIV = new HtmlMeta();
myMetaKeyWords.Name = "keywords";
myMetaKeyWords.Content = "Non-Retail Social Investor, Institutional investor Lender, Not-For-Profit Institutions, CapitalConnect, Social Enterprise, Private Placement Market, Start-up Enterprises, exit option, Social Investment Trends, Double Bottomline, Private Equity management";
myMetaDescription.Name = "Description";
myMetaDescription.Content = "Social enterprise is an organisations that run Non-Retail Social Investor, Institutional investor Lender, Not-For-Profit Institutions.";
myMetaRobot.Name = "robots";
myMetaRobot.Content = "index,follow";
HTTP_EQUIV.HttpEquiv = "Content-Type";
HTTP_EQUIV.Content = "text/html; charset=iso-8859-1";
Page.Header.Controls.Add(myMetaKeyWords);
Page.Header.Controls.Add(myMetaDescription);
Page.Header.Controls.Add(myMetaRobot);
Page.Header.Controls.Add(HTTP_EQUIV);
}