Monday 1 October 2012

How can we convert text to voice in asp.net

Use these namespaces:-

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using SpeechLib;
 
Follow the step to add library reference:- 
Add Reference-----> 
COM---> MicrosoftSpeechObjectLibrary (Add this reference).
 
 

Friday 28 September 2012

Attractive drop down menu using css

Write Down The Code

    <div id="content-wrapper">
  <ul id="hb-menu">
<li><a href="#">Home</a></li>
<li>
<a href="#">Categories</a>
<ul>
<li><a href="#">CSS</a></li>
<li><a href="#">Graphic design</a><ul>
<li><a href="#">Link 1</a></li>
<li><a href="#">Link 2</a></li>
<li><a href="#">Link 3</a></li>
<li><a href="#">Link 4</a></li>
</ul>   </li>

Thursday 27 September 2012

how can we upload and download file in asp.net

Code of upload/insert data in database:- 
 
protected void imgSubmit_Click(object sender, ImageClickEventArgs e)
    {
        SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["con"].ToString());
        SqlCommand cmd = new SqlCommand("application", con);
        cmd.Connection = con;
        cmd.CommandType = CommandType.StoredProcedure;

        if (filephoto.HasFile && filedoc1.HasFile && filedoc2.HasFile && filedoc3.HasFile)
        {
            string fileExt = System.IO.Path.GetExtension(filephoto.FileName);

Friday 21 September 2012

How can we validate .doc,.docx file using javascript

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Untitled Page</title>
<script type="text/javascript" language="javascript">
function validate() {
var uploadcontrol = document.getElementById('<%=FileUpload3.ClientID%>').value;
//Regular Expression for fileupload control.
var reg = /^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))+(.doc|.docx|.DOC|.DOCX)$/;
if (uploadcontrol.length > 0)
{
//Checks with the control value.
if (reg.test(uploadcontrol))
{
return true;
}

Saturday 8 September 2012

How can we select all check box in one click using javascript

<HeaderTemplate>
  <input id="chkAll"  
onclick="javascript:SelectchooseAllCheckboxes(this);" 
              runat="server" type="checkbox" />
</HeaderTemplate> 
 

Saturday 9 June 2012

Important Functions used in sql server 2008/2005

The TOP Clause

The TOP clause is used to specify the number of records to return.
The TOP clause can be very useful on large tables with thousands of records. Returning a large number of records can impact on performance.

 Syntax

SELECT TOP number|percent column_name(s)
FROM table_name

Monday 4 June 2012

How dll hell problem solve in .net

Dll Hell refers to a set of problems caused when multiple 
applications attempt to share a common component like a 
dynamic link library (DLL). The reason for this issue was 
that the version information about the different components 
of an application was not recorded by the system. 

Main Difference between C#3.0 vs c#4.0

C# 4.0
C# 3.5
C# 4.0 supports dynamic programming through dynamic objects.
C# 3.5 does not support dynamic programming.
In C# 4.0, dynamic keyword is associated with objects to represent them as dynamic objects.
The dynamic keyword is not recognized in C# 3.5.
C# 4.0 allows creation of dynamic variables.
Dynamic variables cannot be created in C# 3.5.
In C# 4.0, the method parameters can be specified with default values using optional parameters.
In C# 3.5, method parameters cannot be specified with default values. C# 3.5 does not support optional parameters.
C# 4.0 provides named parameters to represent the values of method parameters without following the order of declaration.
In C# 3.5, method parameters have to be specified in the same order as in method declaration in the method call. C# 3.5 does not provide named parameters.
In C# 4.0, usage of ref keyword is optional while executing methods which are supplied by the COM interfaces.
In C# 3.5, usage of ref keyword is mandatory while executing methods which are supplied by the COM interfaces.
The COM object’s indexed properties are recognized in C# 4.0.
The COM object’s indexed properties are not recognized in C# 3.5.
C# 4.0 enhances Generics by introducing co-variance and contra-variance.
Co-variance and contra-variance are not supported in Generics of C# 3.5.

Friday 1 June 2012

How can we make calculator in vb.net

 This is the simple code of calculator:-

Public Class Form2
    Dim total1 As Integer
    Dim total2 As Integer
    Dim sign As String
    Dim opr As String

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        TextBox1.Text = TextBox1.Text & "0"
    End Sub

Difference between primitive type and non primitive data type in C#

There are two types of data type in C#

primitive data types are the datatypes which are not objects as they are present in c and c++. eg.int,char,float etc.
where as non primitive are the datatypes which are considered as objects eg. String.
This is one of the reason why java is not a purely object oriented lang as the primitive data types are also allowed in java

Thursday 31 May 2012

practical interview questions of c#



Q. Write a program in C# that take string input, and print its number of characters.

string name = Console.ReadLine();
Console.WriteLine(name.Length);
Console.ReadLine();

Q. Write a program in C Sharp that take a sentense as input, and show the number of "a" used in the sentense.

string name = Console.ReadLine();
int counter = 0;
for (int i = 0; i < name.Length; i++)
{
if (name[i] == 'a')
{
counter++;
}

Saturday 19 May 2012

Program of palindrome in c#

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

namespace ConsoleApplication11
{
class Program
{
static void Main(string[] args) {
string str=string .Empty ;
Console.WriteLine("Enter a String name");
string s = Console.ReadLine();
int i = s.Length;
//we can get the Length of string by using Length Property

Friday 18 May 2012

Main difference between web user control & custom control in asp.net

This is from Microsoft's site:
Web user controls
  • Easier to create
  • Limited support for consumers who use a visual design tool
  • A separate copy of the control is required in each application
  • Cannot be added to the Toolbox in Visual Studio
  • Good for static layout

Thursday 17 May 2012

In C# Reverse String Program

public string reverse(string str)
{

int len=str.length;
Char[] arr=new Char[len];
for(int i=0;i<len;i++)
{
  arr[i]= str[len-1-i];
 }

In C# Reverse program of number

int n = 1234567;
int left = n;
int rev = 0;
while(left>0)
{
  r = left % 10;  
  rev = rev * 10 + r;
  left = left / 10; 
}

Console.WriteLine(rev);

Monday 16 April 2012

How can we send encypted data using querystring in asp.net

We usually pass value through query string of the page and then this value is pulled from Request object in another page.

FirstForm.aspx.cs

Response.Redirect(“SecondForm.aspx?item1=” + TextBox1.Text);

SecondForm.aspx.cs

TextBox1.Text = Request. QueryString["item1"].ToString();

After Encryption Send data using query string in asp.net

Sunday 8 April 2012

Tuesday 3 April 2012

How can we implement for and foreach loop in c#

For Loop:-

  int[] myname = new int[1];
        int count = 0;
        for (int i = 0; i < myname.Length; i++)
        {
            count += myname[i];
        }

Friday 30 March 2012

How can we store in multiple table and show in messagebox using vb.net


Imports System.Data
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object,
 ByVal e As System.EventArgs) Handles Button1.Click
    Dim ds As New DataSet
    Dim dt As New DataTable
    Dim dr As DataRow
    Dim idCoulumn As DataColumn
    Dim nameCoulumn As DataColumn
    Dim i As Integer

    idCoulumn = New DataColumn("ID", Type.GetType("System.Int32"))
    nameCoulumn = New DataColumn("Name", Type.GetType("System.String"))

How can we add record using dataset and add record from gridview coloumn using vb.net



 Dim idcoloumn As New DataColumn
    Dim id1coloumn As New DataColumn
    Dim dt As New DataTable

    Dim dr As DataRow
    Dim dr1 As DataRow

Thursday 29 March 2012

In program how can we use dataset in vb.net


    Sub Main()
 'Here is  Two DataTables.
 Dim table1 As DataTable = New DataTable("doctors")
 table1.Columns.Add("name")
 table1.Columns.Add("id")
 table1.Rows.Add("sohan", 1)
 table1.Rows.Add("Waris", 2)

Wednesday 14 March 2012

In asp.net how can we send sms

SENDING SMS IN ASP.NET

Introduction:
                In this article we will see how to send sms from our web application using ozeki-Ng-SMS-Getway.
Pre-Requesite:
1)      For sending sms from our asp.net web application we required third party sms-getway which will deliver our messages to user. You can download this Getway from here http://www.ozekisms.com/index.php?owpn=112.
2)      Mobile Phone whith SIM card and Datacable. Which will be used for sending our sms.

Wednesday 7 March 2012

Main difference between Union and Union All in sql server 2005/2008


UNION

The UNION command is used to select related information from two tables, much like the JOIN command. However, when using the UNION command all selected columns need to be of the same data type. With UNION, only distinct values are selected.

Sunday 4 March 2012

check image accept only png,jpg,gif and Jpeg using javascript

<script language="javascript" type="text/javascript">
 
 function validate() {
      var result = false;
      var upfile = document.getElementById("FileUpload1").value;
      if (upfile != "") {
      var accept = "png,gif,jpg,jpeg".split(',');
      var getExtention = upfile.split('.');
 

how can we fetch data from database using datalist in asp.net


 Firstly make table in sql server like as:-
Create table college
(
id int,
name nvarchar(50),
Category nvarchar(60),
address nvarchar(60),
city nvarchar(50),
phone bigint
);

Main difference between dataset and datatable in ado.net

I have used Datatable and Dataset interchangeably. A Dataset has an overhead perfomance hit when its loaded with a lot of Data. Now let me be more clearer, a Dataset can Contain a lot of Datatable :- A Dataset is like a Container for Datatables because every dataset has a datatable contained inside it and a Datatable is like a table you have in SQL and a Dataset its like a Database that contain table(Datatable).

Friday 2 March 2012

Query string encoding in asp.net

The .NET Framework provides the HttpServerUtility.UrlEncode class to encode the URL.
The following code shows how name and id is passed to abc.aspx page as encoded.
  string id = "11";
  string name = "abc";
  string url = string.Format("abc.aspx?{0}&{11}", Server.UrlEncode(id), 
  Server.UrlEncode(name));
  Response.Redirect(url);

In asp.net three types of session storage described below

InProc:- use like as <sessionState mode="InProc" /> 

Storage location:- Asp.net Process memory area

Description:- This is the default session storage. Session data will be kept in the server memory. InProc mode is a high performance as it reads from the same processes memory and it allows you to keep all .NET types. If session mode is not specified, ASP.NET will use InProc as the default mode.

State server:-
<sessionStatemode="StateServer" stateConnectionStrin
g= "tcpip=Yourservername:42424" /> 

How can we use TOP clause and GETDATE() fucntion in sql

The TOP Clause

The TOP clause is used to specify the number of records to return.
The TOP clause can be very useful on large tables with thousands of records. Returning a large number of records can impact on performance.

GET DATE()

Main difference between execute query and execute nonquery and execute reader in sql server 2005/2008

EXECUTE QUERY

ExecuteQuery() is for command objects i.e., this method will send "select statement" to database and returns value given by the database. Moreover the executeQuery() is not used in .net but it is used in JAVA.

Thursday 1 March 2012

Difference between Delete,Truncate and Drop State ments in sql server 2005/2008

DELETE

The DELETE command is used to remove rows from a table. A WHERE clause can be used to only remove some rows. If no WHERE condition is specified, all rows will be removed. After performing a DELETE operation you need to COMMIT or ROLLBACK the transaction to make the change permanent or to undo it. Note that this operation will cause all DELETE triggers on the table to fire.

TRUNCATE

TRUNCATE removes all rows from a table. The operation cannot be rolled back and no triggers will be fired. As such, TRUCATE is faster and doesn't use as much undo space as a DELETE.

What is the difference between candidate key and primary key

Candidate Key – A Candidate Key can be any column or a combination of columns that can qualify as unique key in database. There can be multiple Candidate Keys in one table. Each Candidate Key can qualify as Primary Key.
Primary Key – A Primary Key is a column or a combination of columns that uniquely identify a record. Only one Candidate Key can be Primary Key.

Monday 27 February 2012

How can we display images in datalist using asp.net

I am using DataList control  but you can easily use same technique for Repeater and GridView control. 
 
<asp:DataList ID="DataList1" runat="server" RepeatColumns="3" RepeatDirection="Horizontal"
   Width="100%" BorderColor="#336699" BorderStyle="Solid" BorderWidth="2px">
  
   <ItemTemplate>
      <asp:Label ID="Label1" runat="server" Text='<%# Eval("ProductName") %>' Font-Bold="True"
         Font-Size="10pt" ForeColor="#336699" Width="100%" />
      <br />
      <asp:Image ID="Image1" runat="server"
         ImageUrl='<%# "GetImage.aspx?id=" + Eval("ProductID") %>' />

   </ItemTemplate>
   <ItemStyle HorizontalAlign="Center" VerticalAlign="Top"  />
</asp:DataList>


Friday 24 February 2012

Difference between CLS and CTS


What is a CLR?
Full form of CLR is Common Language Runtime and it forms the heart of the .NET
framework.All Languages have runtime and its the responsibility of the runtime to take care of
the code execution of the program. Java has Java Virtual Machine, Similarly .NET has CLR.The responsibilities of CLR are Garbage Collection, Code Access Security, Code Verification, IL( Intermediate language ).

Implementation of fragment caching in asp.net

Lets first create a user control.

ASCX PAGE

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="CahceUserControl.ascx.cs"

Inherits="CahceUseControl" %>

<%@ OutputCache Duration="5" VaryByParam="None" %>



<p><asp:Label ID="lblTime" runat="server" EnableViewState="false"

ForeColor="GradientActiveCaption" /></p>

How can we use groupby statement in sqlserver

The GROUP BY clause can be used in a SELECT statement to collect data across multiple records and group the results by one or more columns.
The syntax for the GROUP BY clause is:
SELECT column1, column2, ... column_n, aggregate_function (expression)
FROM tables
WHERE predicates
GROUP BY column1, column2, ... column_n;
aggregate_function can be a function such as sum , count, Min and Max.

Wednesday 22 February 2012

Find the nth highest salary in sql -Query to retrieve value

The following solution is for getting 6th highest salary from Employee table :-
 SELECT TOP 1 salaries
FROM (
SELECT DISTINCT TOP 6 salaries
FROM employee
ORDER BY salary DESC) a
ORDER BY salary


How can we insert image using file upload control using asp.net

1.Firstly create Table
2.Secondly create store procedure

Then .cs page code below:-

if (FileUpload1.HasFile)
            {
                string productname = txtProductName.Text;
                byte[] productimage = FileUpload1.FileBytes;

Wednesday 1 February 2012

Learn about loops in c#

While Loop:- While loop is use when we have to check a condition and then continues to execute a block of code as long as the condition evaluates to boolean value of true.
Syntax:- while (<boolean expression>) { <statements> }.
using System;
                                class whileloops
                                 {
                                    public static void main()
                                       {
                                          int abc=0;
                                          while(abc<20)
                                            {
                                                console.write("{0}", abc)
                                               abc++;
                                              }

Implementation of Interface in C#

An interface is look like classes but in interface have no implementation. It contains the declaration of  events,methods, indexers and properties. Interfaces provide only declaration because they are inherited by classes and structs which must provide implementation for each interface member declared.

Defining an Interface:-
interface IUInterface
{
 void ImplementationToMethod();
}

Tuesday 31 January 2012

Versions of Silverlight

Silverlight 1.0

This is the first release of Silverlight technology in 2007.Originally this release was called WPF/E, which stands for Windows Presentation Foundation/ Everywhere. This release consists of the core presentation framework, which is responsible for UI, interactivity and user input, basic UI controls, graphics and animation, media playback and DOM integration.
The Major drawback of this release is not supporting managed code, which means you can't use .NET supported programming languages for manipulating GUI elements. This was managed by scripting programming languages like Java Script (Only interpretation no compilation), which is hard for non Java Script programmers.

Difference Between silverlignt and wpf

Silverlight and WPF


S.No.
Silverlight
WPF
Definition
The Silverlight is Microsoft's latest development platform for building next-generation Web client applications.
The Windows Presentation Foundation (WPF) is Microsoft's latest development platform for building next-generation Windows client applications.
Subset of
Silverlight is generally considered to be a subset of WPF and is a XAML-based technology that runs within the sandbox of browser plug-in.
WPF is generally considered to be a subset of .NET Framework and is a XMAL based technology.
GUI
Silverlight will be used in development of  Rich Internet Application (RIA) for web client users
WPF will be used in development of Rich Windows Graphical User Interface(GUI) for windows client users

Some Important info about silverlight

Silverlight executes in the client browser.  What does it means. It means:
  • Silverlight applications need to be hosted on a web server
  • Silverlight does NOT need to be hosted in IIS, any web server will do
  • Silverlight does NOT need ASP.NET on the server
  • Silverlight applications cannot access databases without an intermediary (like a web service, WCF service)
  • Silverlight applications cannot access server-side classes or variables without an intermediary (like a web service, WCF service)

What is silverlight?

  • Silverlight is a web browser plug-in.
  • Plug-in is small in size and self-in self-contained.It can be installed on demand.
  • Plug-in runs in all popular browsers, including Microsoft Internet Explorer, Mozilla Firefox, Apple Safari, Opera.
  • Silverlight is a plug-in similar to Flash in a sense. It won't run and use any machine resources until you hit a Page that contains Silverlight application.
  • Pug-in runs cross-browser , cross-platform that exposes a programming framework and features that are a subset of the .NET Framework and Windows Presentation Foundation (WPF)
  • Silverlight is a powerful development platform for creating rich media applications and business applications for the Web, desktop, and mobile devices 

Monday 16 January 2012

What is Sessions?


Web is Stateless, which means a new instance of the web page class is re-created each time the page is posted to the server. As we all know HTTP is a stateless protocol, it can't hold the client information on page. If user inserts some information, and move to the next page, that data will be lost and user would not able to retrieve the information. So what we need? we need to store information. Session provides that facility to store information on server memory. It can support any type of object to store along with our custom object. For every client Session data store separately, means session data is stored as per client basis. Have a look at the following diagram.

Wednesday 11 January 2012

Interfaces and Abstract Class Between Differences

Feature Interface Abstract class
Multiple inheritance A class may inherit several interfaces. A class may inherit only one abstract class.
Default implementation An interface cannot provide any code, just the signature. An abstract class can provide complete, default code and/or just the details that have to be overridden.

Monday 2 January 2012

How can we upload large files in asp.net

Default size is 4MB set already set machine config but you can override it and increase the size:-

<system.web>
  <httpRuntime executionTimeout="240" maxRequestLength="20480" />
</system.web>
 

Sunday 1 January 2012

Disable right click on website using javascript


 
Write this code on javacript to disabling right click:-
 

<script language="javascript">
document.onmousedown=disableclick;
status="Right Click Disabled";
Function disableclick(e)
{
  if(event.button==2)
   {
     alert(status);
     return false; 
   }
}
</script>