Friday, July 20, 2012

Play Wav Sound File in Asp.net Using Java Script

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript">
        var soundObject = null;
        function PlaySound() {
            if (soundObject != null) {
                document.body.removeChild(soundObject);
                soundObject.removed = true;
                soundObject = null;
            }
            soundObject = document.createElement("embed");
            soundObject.setAttribute("src", "sounds/song1.wav");
            soundObject.setAttribute("hidden", true);
            soundObject.setAttribute("autostart", true);
            document.body.appendChild(soundObject);
        }
    </script>
</head>
<body>
    <form id="frm1" runat="server">
        <input type = "btn" onclick = "PlaySound()" value = "Play Sound" />
    </form>
</body>
</html>


ref: Click Here 

Monday, July 16, 2012

Special HTML Codes

Character HTML
Code*
Character
Code
Description of Character   Character HTML
Code*
Character
Code
Description of Character
  &#09;   horizontal tab   Œ &#140;   capital OE ligature
  &#10;   line feed   &#145; &lsquo; left curly quote mark
  &#13;   carriage return   &#146; &rsquo; right curly quote mark/apostrophe
  &#32;   space   &#147; &ldquo; left curly quote marks
! &#33;   exclamation point   &#148; &rdquo; right curly quote marks
" &#34; &quot; straight quote marks   &#149; &bull; bullet
# &#35;   hash mark/number sign   &#150; &ndash; “en” (short) dash
$ &#36;   dollar sign   &#151; &mdash; “em” (long) dash
% &#37;   percent sign   ˜ &#152;   tilde
& &#38; &amp; ampersand   &#153;   trademark
' &#39;   straight quote mark/apostrophe   š &#154;    
( &#40;   left parenthesis   &#155;   right angle quote mark
) &#41;   right parenthesis   œ &#156;   small oe ligature
* &#42;   asterisk   Ÿ &#159;   capital Y, umlaut
+ &#43;   plus sign     &#160; &nbsp; non-breaking space
, &#44;   comma   ¡ &#161; &iexcl; inverted exclamation point
- &#45;   hyphen   ¢ &#162; &cent; cent sign
. &#46;   period/dot   £ &#163; &pound; pound sterling sign
/ &#47; &frasl; slash   ¤ &#164; &curren; general currency sign
0 &#48;   zero   ¥ &#165; &yen; yen sign
1 &#49;   one   ¦ &#166; &brvbar; broken vertical bar
&brkbar;
2 &#50;   two   § &#167; &sect; section sign
3 &#51;   three   ¨ &#168; &uml; umlaut/dieresis
&die;
4 &#52;   four   © &#169; &copy; copyright symbol
5 &#53;   five   ª &#170; &ordf; feminine ordinal
6 &#54;   six   « &#171; &laquo; left angle quote marks
7 &#55;   seven   ¬ &#172; &not; not sign
8 &#56;   eight   ­ &#173; &shy; soft hyphen
9 &#57;   nine   ® &#174; &reg; registered symbol
: &#58;   colon   ¯ &#175; &macr; macron accent
&hibar;
; &#59;   semi-colon   ° &#176; &deg; degree sign
< &#60; &lt; less than sign   ± &#177; &plusmn; plus or minus
= &#61;   equals sign   ² &#178; &sup2; superscript 2
> &#62; &gt; greater than sign   ³ &#179; &sup3; superscript 3
? &#63;   question mark   ´ &#180; &acute; acute accent
@ &#64;   commercial “at” sign   µ &#181; &micro; micro sign (Greek mu)
A &#65;   capital A   &#182; &para; paragraph sign
B &#66;   capital B   · &#183; &middot; middle dot
C &#67;   capital C   ¸ &#184; &cedil; cedilla
D &#68;   capital D   ¹ &#185; &sup1; superscript 1
E &#69;   capital E   º &#186; &ordm; masculine ordinal
F &#70;   capital F   » &#187; &raquo; right angle quote marks
G &#71;   capital G   ¼ &#188; &frac14; fraction one-fourth
H &#72;   capital H   ½ &#189; &frac12; fraction one-half
I &#73;   capital I   ¾ &#190; &frac34; fraction three-fourths
J &#74;   capital J   ¿ &#191; &iquest; inverted question mark
K &#75;   capital K   À &#192; &Agrave; capital A, grave accent
L &#76;   capital L   Á &#193; &Aacute; capital A, acute accent
M &#77;   capital M   Â &#194; &Acirc; capital A, circumflex accent
N &#78;   capital N   Ã &#195; &Atilde; capital A, tilde
O &#79;   capital O   Ä &#196; &Auml; capital A, umlaut/dieresis
P &#80;   capital P   Å &#197; &Aring; capital A, ring
Q &#81;   capital Q   Æ &#198; &Aelig; capital AE ligature, dipthong
R &#82;   capital R   Ç &#199; &Ccedil; capital C, cedilla
S &#83;   capital S   È &#200; &Egrave; capital E, grave accent
T &#84;   capital T   É &#201; &Eacute; capital E, acute accent
U &#85;   capital U   Ê &#202; &Ecicr; capital E, circumflex accent
V &#86;   capital V   Ë &#203; &Euml; capital E, umlaut/dieresis
W &#87;   capital W   Ì &#204; &Igrave; capital I, grave accent
X &#88;   capital X   Í &#205; &Iacute; capital I, acute accent
Y &#89;   capital Y   Î &#206; &Icirc; capital I, circumflex accent
Z &#90;   capital Z   Ï &#207; &Iuml; capital I, umlaut/dieresis mark
[ &#91;   left square bracket   Ð &#208; &ETH; capital Eth, Icelandic
&Dstrok;
\ &#92;   backslash   Ñ &#209; &Ntilde; capital N, tilde
] &#93;   right square bracket   Ò &#210; &Ograve; capital O, grave accent/null set
^ &#94;   caret   Ó &#211; &Oacute; capital O, acute accent
_ &#95;   underscore bar   Ô &#212; &Ocirc; capital O, circumflex accent
` &#96;   grave accent   Õ &#213; &Otilde; capital O, tilde
a &#97;   small a   Ö &#214; &Ouml; capital O, umlaut/dieresis mark
b &#98;   small b   × &#215; &times; multiplication sign
c &#99;   small c   Ø &#216; &Oslash; capital O, slash
d &#100;   small d   Ù &#217; &Ugrave; capital U, grave accent
e &#101;   small e   Ú &#218; &Uacute; capital U, acute accent
f &#102;   small f   Û &#219; &Ucirc; capital U, circumflex accent
g &#103;   small g   Ü &#220; &Uuml; capital U, umlaut/dieresis mark
h &#104;   small h   Ý &#221; &Yacute; capital Y, acute accent
i &#105;   small i   Þ &#222; &THORN; capital Thorn, Icelandic
j &#106;   small j   ß &#223; &szlig; small sz ligature, German
k &#107;   small k   à &#224; &agrave; small a, grave accent
l &#108;   small l   á &#225; &aacute; small a, acute accent
m &#109;   small m   â &#226; &acirc; small a, circumflex accent
n &#110;   small n   ã &#227; &atilde; small a, tilde
o &#111;   small o   ä &#228; &auml; small a, umlaut/dieresis mark
p &#112;   small p   å &#229; &aring; small a, ring
q &#113;   small q   æ &#230; &aelig; small ae ligature, dipthong
r &#114;   small r   ç &#231; &ccedil; small c, cedilla
s &#115;   small s   è &#232; &egrave; small e, grave accent
t &#116;   small t   é &#233; &eacute; small e, acute accent
u &#117;   small u   ê &#234; &ecirc; small e, circumflex accent
v &#118;   small v   ë &#235; &euml; small e, umlaut/dieresis mark
w &#119;   small w   ì &#236; &igrave; small i, grave accent
x &#120;   small x   í &#237; &iacute; small i, acute accent
y &#121;   small y   î &#238; &icirc; small i, circumflex accent
z &#122;   small z   ï &#239; &iuml; small i, umlaut/dieresis mark
{ &#123;   left curly brace   ð &#240; &eth; small eth, Icelandic
| &#124;   solid vertical bar   ñ &#241; &ntilde small n, tilde
} &#125;   right curly brace   ò &#242; &ograve; small o, grave accent
~ &#126;   tilde   ó &#243; &oacute; small o, acute accent
 &#127;   box   ô &#244; &ocirc; small o, circumflex accent
&#128; &euro; euro   õ &#245; &otilde; small o, tilde
&#130;   comma   ö &#246; &ouml; small o, umlaut/dieresis mark
ƒ &#131;   florin   ÷ &#247; &divide; division sign
&#132;       ø &#248; &oslash; small o, slash/null set
&#133;   ellipsis   ù &#249; &ugrave; small u, grave accent
&#134; &dagger; dagger   ú &#250; &uacute; small u, acute accent
&#135; &Dagger; double dagger   û &#251; &ucirc; small u, circumflex accent
ˆ &#136;   circumflex accent   ü &#252; &uuml; small u, umlaut,dieresis mark
&#137; &permil; permil   ý &#253; &yacute; small y, acute accent
Š &#138;       þ &#254; &thorn; small thorn, Icelandic
&#139;   left angle quote mark   ÿ &#255; &yuml; small y, umlaut/dieresis mark

Friday, July 6, 2012

Access Content Page Controls from Master page in Asp.Net

Access Content Page Controls from Master page in Asp.Net


Label cotentlbl = (Label)ContentPlaceHolder1.FindControl("lblContent");
TextBox contenttxt = (TextBox)ContentPlaceHolder1.FindControl("txtContent");
DropDownList contentddl = (DropDownListContentPlaceHolder1) .FindControl("ddlcontent");
masterpagelbl.Text = cotentlbl .Text;
masterpagetxt .Text = contenttxt .Text;
contentddl.SelectedIndex = 0;

 

Access Master Page Controls from Content page in Asp.Net

Access Master Page Controls from Content page in Asp.Net

Label masterpagelbl = (Label)Master.FindControl("lblMaster1");
TextBox masterpagetxt = (TextBox) Master.FindControl("txtMaster1");
 DropDownList masterpageddl = (DropDownList) Master.FindControl("ddlMaster1");
lblContent.Text = masterpagelbl.Text;
txtContent.Text = masterpagetxt .Text;
masterpageddl.SelectedIndex = 0;

Thursday, July 5, 2012

Advantages of SQL Server 2008 over SQL Server 2005?

  • Transparent Data Encryption. The ability to encrypt an entire database.
  • Backup Encryption. Executed at backup time to prevent tampering.
  • External Key Management. Storing Keys separate from the data.
  • Auditing. Monitoring of data access.
  • Data Compression. Fact Table size reduction and improved performance.
  • Resource Governor. Restrict users or groups from consuming high levels or resources.
  • Hot Plug CPU. Add CPUs on the fly.
  • Performance Studio. Collection of performance monitoring tools.
  • Installation improvements. Disk images and service pack uninstall options.
  • Dynamic Development. New ADO and Visual Studio options as well as Dot Net 3.
  • Entity Data Services. Line Of Business (LOB) framework and Entity Query Language (eSQL)
  • LINQ. Development query language for access multiple types of data such as SQL and XML.
  • Data Synchronizing. Development of frequently disconnected applications.
  • Large UDT. No size restriction on UDT.
  • Dates and Times. New data types: Date, Time, Date Time Offset.
  • File Stream. New data type VarBinary(Max) FileStream for managing binary data.
  • Table Value Parameters. The ability to pass an entire table to a stored procedure.
  • Spatial Data. Data type for storing Latitude, Longitude, and GPS entries.
  • Full Text Search. Native Indexes, thesaurus as metadata, and backup ability.
  • SQL Server Integration Service. Improved multiprocessor support and faster lookups.
  • MERGE. TSQL command combining Insert, Update, and Delete.
  • SQL Server Analysis Server. Stack improvements, faster block computations.
  • SQL Server Reporting Server. Improved memory management and better rendering.
  • Microsoft Office 2007. Use OFFICE as an SSRS template. SSRS to WORD.
  • SQL 2000 Support Ends. Mainstream Support for SQL 2000 is coming to an end.

Uploading Multiple Files using JQuery in Asp.Net

Download 2 javascript files (jquery-1.3.2.js) and (jquery.MultiFile.js)

codes
.aspx page
-------------------------------------------------------
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Upload Multiple Files in ASP.NET Using jQuery</title>
        <script src="Scripts/jquery-1.3.2.js" type="text/javascript"></script>
        <script src="Scripts/jquery.MultiFile.js" type="text/javascript"></script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:FileUpload ID="FileUpload1" runat="server" class="multi" />
        <br />
        <asp:Button ID="btnUpload" runat="server" Text="Upload All"
            onclick="btnUpload_Click" />
    </div>
   
    </form>
</body>
</html>
======================================
.aspx.cs page
---------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

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

    }
    protected void btnUpload_Click(object sender, EventArgs e)
    {
        try
        {
            HttpFileCollection hfc = Request.Files;
            for (int i = 0; i < hfc.Count; i++)
            {
                HttpPostedFile hpf = hfc[i];
                if (hpf.ContentLength > 0)
                {
                    hpf.SaveAs(Server.MapPath("docs") + "\\" +
                      System.IO.Path.GetFileName(hpf.FileName));

                }
            }
            Response.Write(hfc.Count + " files are uploaded successfully.");
        }
        catch (Exception ex)
        {
            Response.Write("Error in Uploading !!!");
        }
    }
}

Download Code

Compare system DateTime and user input DateTime in asp.net with c#

protected void Button1_Click(object sender, EventArgs e)
    {
        string dt1 = DateTime.Now.ToString("MM/dd/yyyy");
        string dt2 = TextBox1.Text;
        if (dt1 == dt2)
        {
            TextBox1.Text = "Correct date";
        }
        else TextBox1.Text = "Wrong Date";
    }

Wednesday, July 4, 2012

Create Folder on Server at Runtime Using Asp.Net

.Aspx Code
------------------------------
<div>
    Directory Name : <asp:TextBox ID="txtdir" runat="server"></asp:TextBox>
        <br />

    <asp:Button ID="btn" runat="server" Text="Create Directory" onclick="btn_Click" />
        <br />

    <asp:Label ID="lbl" runat="server" ></asp:Label>
    </div>
-------------------------------

.Aspx.Cs

-------------------------------

using System.IO;

protected void btn_Click(object sender, EventArgs e)
    {
        string Path = Server.MapPath("~/") +txtdir.Text.Trim();
        if (!Directory.Exists(Path))
        {
            Directory.CreateDirectory(Path);
            lbl.Text = "Directory created successfully";
        }
        else
            lbl.Text = "Directory already exists";
    }

Tuesday, July 3, 2012

All selected values from a CheckBoxList ASP.NET



private Int32[] CheckboxListSelections(System.Web.UI.WebControls.CheckBoxList list)
    {
        ArrayList values = new ArrayList();
        for (int counter = 0; counter < list.Items.Count; counter++)
        {
            if (list.Items[counter].Selected)
            {
                values.Add(list.Items[counter].Value);
            }
        }
        return (Int32[])values.ToArray(typeof(Int32));
    }



ref:- Check it