Showing posts with label Javascript. Show all posts
Showing posts with label Javascript. Show all posts

Tuesday, September 10, 2013

Interview Questions :- .NET,ASP.NET , SQL Server , C#, SharePoint, Javascript, Jquery

Hey All,
   Below are some Questions ( not answers :-) ) that are asked in interviews that I have faced. Hope they prove useful to you for your preparation at some point of time.

 The Questions are mixed of : ASP.NET , SQL Server , .NET Framework , SharePoint , C# , OOPS


  1. What are magic tables in SQL Server 
  2.  How many and what are temp tables in Sql Server ?
  3.  How will you call trigger in Sql Server ?
  4.  How will you call function in Sql Server ?
  5.   There are 2 tables A and B having 3 columns each...What is the output of " Select * from A,B?
  6.   What is the maximum number of Clustered indexes a table can have ?
  7.  when you update a table in SQL Server management studio .., what exactly happens ?
  8.  What is project life cycle?
  9.  What are the differences b/w SQL Server 2008 and SQL Server 2012?
  10.  What is the difference between Site Template and Site Definition?
  11.  What are Generics in C# ? What is the use of it ?
  12.  Protected vs Protected Internal in C# ?
  13.  can we create master page through sharepoint desginer ?
  14.  what is the difference between creating items through sharepoint designer and sharepoint server?
  15.  ASP.NET page life cycle?
  16.  when can we change page's Viewstate ? on which event ?
  17.  can you create site template ? how ?
  18.  what is the prurpose of SPSecurity class in SharePoint ?
  19.  what is Code access security in .NET ?
  20.  There are 2 tables A and B... A has 3 columns , 5 rows ... B has 2 columns , 3 rows ..What will be the output of  a) Select * from A,B b) cross join between 2 tables (how many rows and columns will a cross join between 2 tables return ?)
  21.  What are Cross joins ?
  22. how will update sharepoint list ? write the code.
  23.  what are extension methods in C#?
  24.  what are anonymous methods in c#?
  25.  why multiple inheritance is not possible in C#?
  26. what is a site column in SharePoint?
  27. Difference b/w sandboxed and Farm solution?
  28.  Difference b/w Web Parts and Visual Web Parts.
  29.  how to make a master page in Sharepoint Site?
  30.  abstract class vs interfaces
  31.   Explain Sharepoint Object Model
  32.  What are SPutility and SPMetal in SharePoint ?
  33.  What is .wsdl file in a web service ? 
  34.  how many ways you handle erors in a web page ?
  35.  HttpUtility class vs Http Module
  36.  Can you run JSP pages in IIS ? How ?
  37.  which exception will first occur ?inside BAL , DAL , or UI layers'?
  38.  What does theme in CSS contains ?
  39.  What are views in SQL Server ? can we perform DML in Views?
  40.  User Defined Functions Vs Stored Procedure?
  41.  Difference b/w SQL variable @ and @@
  42.  Difference between Hidden Field vs Viewstate ?
  43.  Boxing and Unboxing difference
  44. What are extension methods and extension classes in C#?
  45.  Inproc vs Outproc in Stored Procedures?
  46.  HTTP module vs HTTP handler
  47.  HTTP get vs HTTP Post?
  48. Abstraction vs Encapsulation
  49.  overloded methods can have different return type?
  50.  static class vs Sealed classes .. why are they used ?
  51.  polymorphism in C#
  52.  types of triggers in SQL SERVER
  53.  Left outer join in SQL SERVER
  54.  What are indexes in SQL SERVER
  55.  What are cursors in SQL Server
  56.  What is the new keyword in Method overriding?
  57.  What are different types of views in SQL Server?
  58.  what is a $ sign in Jquery ?
  59.  How will you enable a website to run only for indian country?
  60.  what are lambda expressions in C#?
  61.  what is difference between array and arraylist ? when to use what and which one is faster?
  62.  what is datareader ? how is it different from dataset?
  63.  What are out, ref parameter in C# method?
  64.  For vs ForEach loop
  65. what is the benefit of putting the .wsp or solution file inside GAC and inside BIN?
  66.  what is RunWithElevatedPrivileges in SharePoint?
  67.  what is the difference between webpart and Visual WebPart?
  68.  what is the difference between Sytem.web.UI.WebControls.Webparts.WebPart vs Microsoft.Sharepoint.WebPart?
  69.  Abstraction Vs Encapsulation
  70.  What is viewstate ? Can you store collections in Viewstate?
  71.  What is the difference between Stored Procedures and User Defined Functions in Sql Server ?
  72.  What is LINQ and advantages of LINQ ?
  73.  I have a collection of strings , Which will be more efficient LINQ or normal for / for each loop?
  74.  What are the ways of storing information into clients computers?
  75.  What are Selectors in Jquery ?
  76.  What are the advantages of Entity Framework?
  77.  Request vs Response Cycle of a Page?
  78. Limitations of sharepoint designer
  79. how will you create master pages and how will you deploy?
  80.  what is a feature ? how will you deploy feature?
  81.  how will you associate one content type to 3 lists ?
  82.  What is caching ? How many types of caching is there?
  83.  What is the difference between caching and session ?
  84.  Generic list vs arraylist vs array in terms of performance and why ?
  85.  why serialization is done and what are the types of serialization?
  86.  What is the difference b/w caching and Session ?
  87. Difference b/w httphandlers and http modules.
  88.  what are the limitations or disadvandtages of Generics
  89.  how to find the 4th highest salary in table?
  90.  .net 2.0 vs .net 4.0 features
  91.  What is garbage collector ?
  92.  garbage collector dispose vs finalize 
  93.  what are table valued functions in SQL Server
  94.  What are shared assemblies
  95.  What is Isnull and collasce operator in SQL Server?
  96.  interface vs abstract class
  97.  return server date in javascript 
  98.  how to increment each salary of all employees with 500 
  99.  how to work with cookies in asp.net 
  100.  javascript function on html control click and asp.net control click

    ALL THE VERY BEST !!!

Friday, February 17, 2012

Add Twitter and Facebook like Social Sites link to ASP.NET WebSite

Hi All,
      This is my first post of the year 2012.
I came across one requirement in my recent project in which where i do have to add two share buttons for two most popular social networking sites Facebook and Twitter.

I found this HTML code to be placed in any asp.net site . Below is the code:

<a href="http://twitter.com/home?status=" target="_blank" onclick="window.open(this.href, this.target,'height=500px,width=400px'); return false">

  <img src="Images/twitter.png" alt="Share on Twitter" />

a>

<a href="http://www.facebook.com/connect/prompt_feed.php?&message=" target="_blank" onclick="window.open(this.href, this.target,'height=500px,width=400px'); return false">
  
<img src="Images/facebook.png" alt="Share on Twitter" />

a>




Thats it...and  you are ready with the share button.

Below is the snapshot of  the rendered page after click on facebook and twitter image link.

Clicking on Twitter image opens the below page as a pop up:


Clicking on Facebook image opens the below page as a pop up:





This is for sharing your own  on these two networking sites but not shareing the link or any other outside matter.


Thanks,
Nitin Sharma

Happy Coding..!!!





Wednesday, January 13, 2010

How to Detect/Find Page is Loaded

Hi All,
You my want to know sometimes that is the page loaded completely?
This simple javascript function can let you know:

var body = document.getElementsByTagName('BODY')[0];

if (body && body.readyState == 'loaded')

{
AfterLoad();
}

else
{
if (window.addEventListener)

{
window.addEventListener('load', AfterLoad, false);
}

else
{
window.attachEvent('onload', AfterLoad);
}
}
function AfterLoad()

{
alert("page loaded !!!");
}


Thats it...

Thanks,
Nitin Sharma

Wednesday, May 6, 2009

Javascript and Master Pages

Calling JavaScript from ASP.NET Master Page and Content Pages - Part I

 

 

Call JavaScript From Master Page

You can call an existing JavaScript function from a Master Page or can create one on the fly. Here are some common scenarios:

1. Create a JavaScript function on the fly and call the JavaScript function in the MasterPage Page_Load() event

C#

    protected void Page_Load(object sender, EventArgs e)

    {

        string someScript = "";

        someScript = "";

        Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", someScript);

    }

 

The Page.ClientScript.RegisterStartupScript() allows you to emit client-side script blocks from code behind. More info can be found over here http://msdn.microsoft.com/en-us/library/system.web.ui.clientscriptmanager.registerstartupscript.aspx

2. Call an existing JavaScript function on MasterPage Page_Load() event

Let us assume you have an existing JavaScript function declared in between the tags, then here’s how to call that function from Page_Load()

<head runat="server">

    <title>title>

    <script type="text/javascript">

        function invokeMeMaster() {

            alert('I was invoked from Master');

        }

    script>

    <asp:ContentPlaceHolder id="head" runat="server">

    asp:ContentPlaceHolder>

head>

    protected void Page_Load(object sender, EventArgs e)

    {

        if (!Page.ClientScript.IsStartupScriptRegistered("alert"))

        {

            Page.ClientScript.RegisterStartupScript

                (this.GetType(), "alert", "invokeMeMaster();", true);

        }

 

    }

3. Call JavaScript function from MasterPage on Button click

If you want to call a JavaScript function on a Button click, then here’s how to do so:

<head runat="server">

    <title>title>

    <script type="text/javascript">

        function invokeMeMaster() {

            alert('I was invoked from Masterdotnetcurry');

        }

    script>

    <asp:ContentPlaceHolder id="head" runat="server">

    asp:ContentPlaceHolder>

head>

In the tag, add a Button and use the OnClientClick to call this function

<asp:Button ID="btnMaster" runat="server" Text="Button"OnClientClick="return invokeMeMaster();"/>

 

The OnClientClick() is called before the postback occurs. This gives us a place to check for some condition and cancel the submit if the condition is not satisfied. We will see an example in Tip 6.

4. Access a control on the MasterPage using JavaScript

If you have a control on the MasterPage and need to access it using JavaScript, then here’s how to do so. In this sample, we will test the length of the TextBox to see if there are 5 or more letters. If the number of letters is less than 5, the form submit will be cancelled.

Add a TextBox and a Button control in the MasterPage (outside the ContentPlaceHolder) as shown below

<body>

    <form id="form1" runat="server">

    <div>

       <asp:Panel ID="panelMaster" GroupingText="MasterPage controls"runat="server">      

            <asp:TextBox ID="txtMaster" runat="server">asp:TextBox>

            <asp:Button ID="btnMaster" runat="server" Text="Button"OnClientClick="return accessMasterControl();" />

            <br />

        asp:Panel>

        <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">

       

        asp:ContentPlaceHolder>

    div>

    form>

body>

In the element of the MasterPage, add the following code:

<head runat="server">

    <title>title>

    <script type="text/javascript">

        function accessMasterControl() {

            if(document.getElementById('').value.length <= 5) {

                alert('Minimum 5 characters required')

                return false;

            }

            else { return true;}

        }

    script>

    <asp:ContentPlaceHolder id="head" runat="server">

    asp:ContentPlaceHolder>

head>

5. Access a control on the Content Page from a MasterPage using JavaScript

If you have a control on the Content Page which has to be accessed in the MasterPage using JavaScript, then here’s how to do so:

On the Content Page, create a TextBox as shown below :

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1"Runat="Server">

    <asp:Panel ID="panelContent" GroupingText="ContentPage Controls"runat="server">

        <asp:TextBox ID="txtContent" runat="server">asp:TextBox>

    asp:Panel>

asp:Content>

 

Now access and populate the TextBox ‘txtContent’ from the MasterPage

<head runat="server">

    <title>title>

    <script type="text/javascript">

        function accessControlContentPage() {

var txtCont = document.getElementById('');

    txtCont.value = "I got populated using Master Page";               

}

    script>

    <asp:ContentPlaceHolder id="head" runat="server">

    asp:ContentPlaceHolder>

head>

6. Ask user before submitting the form on a MasterPage

In order to ask the user for a confirmation before submitting the form, you can either use code behind or can use simple mark up as shown below:

Declare a Button control that causes postback and write the following code in MasterPage.master.cs

protected void Page_Load(object sender, EventArgs e)

{

    string myScript = @"";

    Page.ClientScript.RegisterClientScriptBlock(this.GetType(),"MakeSure", myScript);

    form1.Attributes.Add("onsubmit", "return askBeforeSubmit();");

}

If you want to avoid a code-behind approach, you can ask the user for a confirmation by using the OnClientClick() on the Submit button

<asp:Button ID="btnMaster" runat="server" Text="Button"

OnClientClick="return confirm('Are you sure?');"/>

 

Calling JavaScript from ASP.NET Master Page and Content Pages - Part II

Call JavaScript from Content Page

Here are some common scenarios of executing JavaScript from a Content Page.

1. Create a JavaScript function on the fly and call the JavaScript function in the Content Page Page_Load() event

    protected void Page_Load(object sender, EventArgs e)

    {       

        const string someScript = "alertMe";

        if (!ClientScript.IsStartupScriptRegistered(this.GetType(), someScript))

        {

            ClientScript.RegisterStartupScript(this.GetType(),

                someScript, "alert('I was called from Content page!')",true);

        }

    }

2. Call a JavaScript function declared in a .js file from the Content Page

If you have a .js file and want to call the function from your Content Page, then here’s how to do so.

Let’s create a .js file called TestScript.js and add the following function in the .js file.

function insideJS() {

    alert('Inside .js');

}

Assuming that your .js file is kept in a Script folder, reference the file in your MasterPage in the following manner.

<head runat="server">

    <title>title>

    <script src="Scripts/TestScript.js" type="text/javascript">script>

...

Now in your Content Page(in our case Default.aspx.cs ), call the JavaScript function on the Page_Load:

 

    protected void Page_Load(object sender, EventArgs e)

    {       

        if (!Master.Page.ClientScript.IsStartupScriptRegistered("alert"))

        {

            Master.Page.ClientScript.RegisterStartupScript

                (this.GetType(), "alert", "insideJS();", true);

        }

    }

 

3. Referencing the .js file from a Content Page instead of the Master page

The approach shown above in Tip 2 works well, however this approach would add a reference to the .js file for every page in the application (since we are adding the .js in the Master Page). If you want to avoid this approach, then remove the reference added to the .js file in Tip 2 in the Master Page. Now add a reference to the .js file from the Content Page using the ‘RegisterClientScriptInclude’ as shown below:

    protected void Page_Load(object sender, EventArgs e)

    {

        Page.ClientScript.RegisterClientScriptInclude("selective", ResolveUrl(@"Scripts\TestScript.js"));

        if (!Master.Page.ClientScript.IsStartupScriptRegistered("alert"))

        {

            Master.Page.ClientScript.RegisterStartupScript

                (this.GetType(), "alert", "insideJS();", true);

        }

    }

Using this approach, we can avoid referencing the .js file for every content page.

Note: This approach adds the JavaScript reference inside the tag of the page.

4. Declare JavaScript inside the Content page and execute it

If you are looking out to declare JavaScript inside the Content Page, then here’s how to do so. Add the following markup inside the Content page (in our case Default.aspx)

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1"Runat="Server">

    <asp:Panel ID="panelContent" GroupingText="ContentPage Controls"runat="server">

        <asp:TextBox ID="txtContent" runat="server">asp:TextBox>

        <asp:Button ID="btnContent" runat="server" Text="Button"OnClientClick="Populate();" />

    asp:Panel>

    <script type="text/javascript" language="javascript">

        function Populate() {

            {

                document.getElementById('').value = "Hi";               

            }

        }

    script>

asp:Content>

The markup shown above populates the textbox with some text on a button click.

5. Accessing a Control on the Master Page From a ContentPage using JavaScript

In our previous article, we saw how in Tip 5 To access a control on the ContentPage From a Master Page using JavaScript. In this tip, we will see how to access a control kept on the MasterPage from a ContentPage. Do the following:

We have added a textbox control to the of the MasterPage  as shown below:

<body>

    <form id="form1" runat="server">

    <div>

        <asp:Panel ID="panelMaster" GroupingText="MasterPage controls"runat="server">      

            <asp:TextBox ID="txtMaster" runat="server">asp:TextBox>

            <br />

        asp:Panel>

        <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">

       

        asp:ContentPlaceHolder>

    div>

    form>

body>

We will now access this TextBox ‘txtMaster’ in the ContentPage using JavaScript

To do so, go to the Content page (Default.aspx) and add the following line below the directive to register the MasterPage

...

...

Now in the code behind of Default.aspx.cs , access the MasterPage control in the following manner

   protected void Page_Load(object sender, EventArgs e)

    {

        TextBox tb = (TextBox)Master.FindControl("txtMaster");

        string val = tb.ClientID;

        string script = @"";

        if (!Page.ClientScript.IsStartupScriptRegistered("Mast"))

        {

            Page.ClientScript.RegisterStartupScript(this.GetType(),

                "Mast", script);

        }

 

    }

Observe how we have used the RegisterStartupScript instead of RegisterClientScriptBlock. The main difference is that the 'RegisterStartupScript' method places the JavaScript at the bottom of the ASP.NET page right before the closing element whereas the 'RegisterClientScriptBlock' method places the JavaScript directly after the opening

element in the page. Had we used the 'RegisterClientScriptBlock', the browser would have executed the JavaScript before the text box is on the page. Therefore, the JavaScript would not have been able to find a ‘txtMaster’ and would give a control not found error. Understanding this simple difference between the two methods can save you hours of work!

6. Call JavaScript function from an ASP.NET AJAX enabled Content Page

If your content page is wrapped in an ASP.NET AJAX UpdatePanel, then you cannot use the ClientScript.RegisterStartupScript to call a JavaScript function during a partial-page postback. Instead, use the ScriptManager.RegisterStartupScript() method.

    protected void Page_Load(object sender, EventArgs e)

    {

        System.Text.StringBuilder sb = new System.Text.StringBuilder();

        sb.Append(@"");

 

        ScriptManager.RegisterStartupScript(this, this.GetType(), "ajax", sb.ToString(), false);

 

    }

Observe that the last parameter for RegisterStartupScript() is set to 'false'. This means that the



Source: http://www.dotnetcurry.com/ShowArticle.aspx?ID=274 




Thanks,

Nitin Sharma