Saturday, 24 July 2010

Interview Question sabkahub


Sabkahub Services Pvt Ltd,
ASP.NET, C#, SQL SERVER                                                                                           Time Duration: 30 min
______________________________________________________________________________________                            

1 Question :

Which of the following are correct controls in ASP.NET Source View?()

1.<asp:textbox runat="server" id="Msg" text="Hello, R4R" />

2.<asp:button runat="server" id="Send" text="Send" onclick="Send_Click" />

3. None

4. Both

Answer : 4 Both

2 Question :
Which is used to add event code(on C# Code) for TextBox control in Source view ( ASP.NET)

1.         MsgSent.Text = Msg.Text;
2.         MsgSent.Text = Msg.Text
3.         Both
4.         None

Answer :1

3 Question :
Which is used for code-in-line model?
1.< script runat="server">
2.< script javascript="server">
3.Both
4.None

Answer:1

4 Question :
Which is code allows the modification of the head tag at runtime?
1 < head runat="server">
2.< script javascript="server">
3.Both
4.None

Answer :1

5 Question :
How you can change the page title by changing the  using C#

1.void buttonSet_Click(Object sender, EventArgs earg)
{
Header.Title :Msg.Text;
}
2.void buttonSet_Click(Object sender, EventArgs earg)
{
 Msg.Text= Header.Title;
}

3.void buttonSet_Click(Object sender, EventArgs earg)
{
Msg.Text: Header.Title;
}

4.None
Answer : 1

6 Question :
Which is not used into @Page attributes
1. Async ,CodeFile
2. EnableTheming, MasterPageFile
3. MaintainScrollPositionOnPostback Theme
4. None
5. All
Answer : 4

7 Question :
ASP.NET Supports “Nested Master Page”
1.Yes
2.No

Answer :1

8 Question :
Choose correct Template Within a DataList tag which we  can customize
1.AlternatingItemTemplate
2.EditItemTemplate
3.FooterTemplate
4.HeaderTemplate
5.ItemTemplate
6.SelectedItemTemplate
7.SeparatorTemplate

A 1,2,3,4,5
B 1,3,4,5
C 14,5,7
D 1,2,3,4
E,1,2,3,4,5,6,7

Answer :E

9  Write a query to find the days between 12/01/2009 – 12/12/2009.

Answer SELECT DATEDIFF(dd,"24 March 1964","24 March 2001")

10 Does C# support multiple-inheritance? 
Answer :yes

11 Is XML case-sensitive? 
Answer :yes

12 what is the size of object in c#.
Answer : 8 byts

13 write Update Query in Sql Server :
Answer :
update table_name set Colunm_Name = ‘condition’  where Colunm_Name = 'Argos'

14 What data types does the RangeValidator control support?
Answer : Integer, String, and Date.,

15 How many classes can a single .NET DLL contain?
Answer : many class

16 What is difference between dll and exe?
Answer :
DLL

1. It can be reused.
2. It can be versioned.
3. It is not self executable
4. It doesn't have main function

.EXE
1. It cannot be reused
2. It cannot be versioned.
3. It is self executable.
4. It will have main function.

17 What is View State?
Answer : ViewState allows the state of objects (serializable) to be stored in a hidden field on the page. ViewState is transported to the client and back to the server, and is not stored on the server or any other external source. ViewState is used the retain the state of server-side objects between postabacks.

18 Can you store multiple data types in System. Array?
Answer :  NO

19 What’s the top .NET class that everything is derived from? 
Answer : System.object

20 Will the finally block get executed if an exception has not occurred?
Answer : Yes

21 Can multiple catch blocks be executed for a single try statement?
Answer :  yes

22 What does the term immutable mean?
Answer : immutable means we can not change the contents at run time,
example of immutable is String

23 write code for JavaScript to refresh a page in 5 second
Answer :
 <!-- Codes by Quackit.com -->
<script type="text/JavaScript">
<!--
function timedRefresh(timeoutPeriod) {
            setTimeout("location.reload(true);",timeoutPeriod);
}
//   -->
</script>
<p>
<a href="javascript:timedRefresh(2000)">Refresh this page in 2 seconds</a> |
<a href="javascript:timedRefresh(5000)">Refresh this page in 5 seconds</a>
</p>

24 Name two properties common in every validation control?
Answer :  ControlToValidate property and Text property.


25 Write A Query To Remove The Duplicate Value From A Table
Answer : delete table_name where col_name in(select col_name from table_name group by
col_name having count(*) > 1)



Friday, 23 July 2010

Simple Captcha with ASP.Net


Simple Captcha with ASP.Net

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>

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

         var a = 49, b = 65;

         var c = 100;

         var d = 70;

  function show()

  {

      if (a == 57) {

          a = 49;

      }



      var main = document.getElementById('txt1');

      var a1 = String.fromCharCode(a);

      var b1 = String.fromCharCode(b);

      var c1 = String.fromCharCode(c);

      var d1 = String.fromCharCode(d);



      main.value = a1 + b1 + c1 + d1;

a = a + 1;

b = b + 2;

c = c + 1;

d = d + 2;

  }

    </script>

    <style type="text/css">

        #form1

        {

            height: 95px;

        }

    </style>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <input type="text" id="txt1" runat="server" style="border-style: none; border-color: inherit;
                border-width: medium; background-color: Green; color: red; font-family: 'Curlz MT';
                font-size: x-large; font-weight: bold; font-variant: normal; letter-spacing: 10pt;
                width: 120px; background-image: url('glitter_background_b4.gif');" value="5AbD" />
            <input type="button" onclick="show()" value="Change" />
        </div>
        <asp:TextBox ID="txtverification" runat="server"></asp:TextBox>
        &nbsp;&nbsp;&nbsp;&nbsp;
        <asp:Button ID="Button1" runat="server" Text="Verification" OnClick="Button1_Click" />
        &nbsp;&nbsp;&nbsp;&nbsp;
        <asp:Label ID="lblmsg" runat="server" Font-Bold="True" ForeColor="Red"></asp:Label>



<div>
      <asp:CustomValidator ID="CustomValidator2" runat="server" ControlToValidate="txtVerify"
            ErrorMessage="You have Entered a Wrong Verification Code!Please Re-enter!!!" OnServerValidate="CAPTCHAValidate"></asp:CustomValidator>     
     <asp:Image ID="imCaptcha" ImageUrl="" runat="server" />
        <asp:TextBox ID="txtVerify" runat="server"></asp:TextBox>
        <asp:Button ID="btnSave" runat="server" Text="Save" /></div


    </form>
</body>
</html>




using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Drawing;

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

    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        if (txtverification.Text == txt1.Value)
        {

            lblmsg.Text = "Correct";

        }

        else
        {

            lblmsg.Text = "Incorrect Code";

        }
    }
}

Sunday, 18 July 2010

how to send sms from asp.net


Code For Default.aspx Page


<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="smssend.aspx.cs" Inherits="_Default" validateRequest="false" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>sunilgurjar.blogspot SMS Gateway Message Sending Example</title>
</head>
<body>
    <center>
    <form id="smsdata" runat="server">
        <asp:Table id="smstable" runat="server" style="text-align:left; border-width:thin; border-color:Silver;" BorderStyle="Solid">
            <asp:TableRow>
                <asp:TableCell ColumnSpan="2">
                    <b>Compose a message:</b>
                    <br />
                    <br />
                </asp:TableCell>
            </asp:TableRow>
            <asp:TableRow>
                <asp:TableCell HorizontalAlign="Left" VerticalAlign="Top">
                    <asp:Label ID="labelRecipient" runat="server" Text="Recipient: "></asp:Label>
                </asp:TableCell>
                <asp:TableCell>
                    <asp:TextBox ID="textboxRecipient" runat="server"></asp:TextBox>
                </asp:TableCell>
            </asp:TableRow>
            <asp:TableRow>
                <asp:TableCell HorizontalAlign="Left" VerticalAlign="Top">
                    <asp:Label ID="labelMessage" runat="server" Text="Message Text: "></asp:Label>
                </asp:TableCell>
                <asp:TableCell>
                    <asp:TextBox ID="textboxMessage" runat="server" TextMode="MultiLine"></asp:TextBox>
                </asp:TableCell>
            </asp:TableRow>
            <asp:TableRow>
                <asp:TableCell ColumnSpan="2" HorizontalAlign="Center">
                    <asp:Button ID="buttonSend" runat="server" Text="Send Message" OnClick="buttonSendOnClick" />
                </asp:TableCell>
            </asp:TableRow>
            <asp:TableRow>
                <asp:TableCell ColumnSpan="2" HorizontalAlign="Center">
                    <asp:TextBox ID="textboxError" runat="server" BorderStyle="None" TextMode="MultiLine"></asp:TextBox>
                </asp:TableCell>
            </asp:TableRow>
        </asp:Table>
    </form>
    </center>
</body>
</html>

Code For Default.aspx.cs Page

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net;
using System.Net.Mail;
using System.Text.RegularExpressions;

public partial class _Default : System.Web.UI.Page
{
   

    protected void Page_Load(object sender, EventArgs e)
    {
        textboxRecipient.Width = 400;
        textboxMessage.Width = 450;
        textboxMessage.Rows = 10;
        textboxError.Width = 400;
        textboxError.Rows = 5;

        textboxError.ForeColor = System.Drawing.Color.Red;
        textboxError.Visible = false;
        textboxError.Text = "";

        if (!Page.IsPostBack)
        {
            textboxRecipient.Text = "8010771150";
            textboxMessage.Text = "Hello World!";
        }
    }

    protected void buttonSendOnClick(object sender, EventArgs e)
    {
        //are required fields filled in:
        if (textboxRecipient.Text == "")
        {
            textboxError.Text += "Recipient(s) field must not be empty!\n";
            textboxError.Visible = true;
            return;
        }

        //we creating the necessary URL string:
        string SunilSURL = "http://127.0.0.1"; //where sunilgurjar.blogspot SMS Gateway is running
        string SunilSPort = "9501"; //port number where sunilgurjar.blogspot SMS Gateway is listening
        string SunilUser = HttpUtility.UrlEncode("admin"); //username for successful login
        string SunilPassw = HttpUtility.UrlEncode("admin"); //user's password
        string SunilMessageType = "SMS:TEXT"; //type of message
        string SunilRecipients = HttpUtility.UrlEncode(textboxRecipient.Text); //who will get the message
        string SunilMessageData = HttpUtility.UrlEncode(textboxMessage.Text); //body of message

        string createdURL = SunilSURL + ":" + SunilSPort + "/httpapi" +
            "?action=sendMessage" +
            "&username=" + SunilUser +
            "&password=" + SunilPassw +
            "&messageType=" + SunilMessageType +
            "&recipient=" + SunilRecipients +
            "&messageData=" + SunilMessageData;

        try
        {
            //Create the request and send data to sunilgurjar.blogspot SMS Gateway Server by HTTP connection
            HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(createdURL);

            //Get response from sunilgurjar.blogspot SMS Gateway Server and read the answer
            HttpWebResponse myResp = (HttpWebResponse)myReq.GetResponse();
            System.IO.StreamReader respStreamReader = new System.IO.StreamReader(myResp.GetResponseStream());
            string responseString = respStreamReader.ReadToEnd();
            respStreamReader.Close();
            myResp.Close();

            //inform the user
            textboxError.Text = responseString;
            textboxError.Visible = true;
        }
        catch (Exception)
        {
            //if sending request or getting response is not successful sunilgurjar.blogspot SMS Gateway Server may do not run
            textboxError.Text = "sunilgurjar.blogspot  SMS Gateway Server is not running!";
            textboxError.Visible = true;
        }

    }
}


Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Powered by Blogger