ASP.NET Submit form on Enter Key Default submit Button

July 12th, 2010 by Nishan

Set the defaultbutton property on Form. If you are using panels use panel property.

<body>
<form id=”form1″ defaultfocus=”TextBox1″ defaultbutton=”Button1″ runat=”server”>
<div>
<asp:TextBox ID=”TextBox1″ runat=”server”></asp:TextBox>
<asp:Button ID=”Button1″ runat=”server” Text=”Button” />
</div>
</form>
</body>

Posted in .net | No Comments »

ASP.net Set cursor position in TextBox

July 12th, 2010 by Nishan

<form id=”form1″ defaultfocus=”TextBox1″ runat=”server”>
<div>
<asp:TextBox ID=”TextBox1″ runat=”server”></asp:TextBox>
</div>
</form>

Set the  defaultfocus to Textbox

Posted in .net | No Comments »

Execute Asp.net button Click from Javascript

April 29th, 2010 by Nishan

function submit_form()
{
if ((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13))
{
document.all(‘<%= btnSubmit.ClientID %>’).click();
return false;
}
else
{return true;}
}

Posted in .net | No Comments »

Online File Convertor

April 29th, 2010 by Nishan

Following are the formats you can converts online on http://www.zamzar.com

Documents you can convert.

CONVERT FROM                                                         TO

csv – Comma Separated Values doc – Microsoft Word Document
html – Hypertext Markup Language
mdb – Microsoft Access Database
ods – OpenDocument spreadsheet
pdf – Portable Document Format
rtf – Rich text format
xls – Microsoft Excel Spreadsheet
xml – Extensible Markup Language
doc – Microsoft Word Document html – Hypertext Markup Language
odt – OpenDocument Text Document
pcx – Paintbrush Bitmap Image
pdf – Portable Document Format
png – Portable Network Graphic
ps – Postscript document
txt – Text document
odp – OpenDocument presentation html – Hypertext Markup Language
pcx – Paintbrush Bitmap Image
pdf – Portable Document Format
png – Portable Network Graphic
ppt – Microsoft Powerpoint Presentation
ps – Postscript document
swf – Macromedia Flash Format File
ods – OpenDocument spreadsheet csv – Comma Separated Values
doc – Portable Network Graphic
html – Hypertext Markup Language
mdb – Microsoft Access Database
pdf – Portable Document Format
rtf – Rich Text format
xls – Microsoft Excel Spreadsheet
xml – Extensible Markup Language
odt – OpenDocument Text Document doc – Microsoft Word Document
html – Hypertext Markup Language
pdf – Portable Document Format
png – Portable Network Graphic
ps – Postscript document
txt – Text document
pdf – Portable Document Format doc – Microsoft Word Document
html – Hypertext Markup Language
odt – OpenDocument Text Document
pcx – Paintbrush Bitmap Image
png – Portable Network Graphic
ps – Postscript document
rtf – Rich Text Format
txt – Text document
ppt – Microsoft PowerPoint Presentation html – Hypertext Markup Language
odp – OpenDocument presentation
pcx – Paintbrush Bitmap Image
pdf – Portable Document Format
png – Portable Network Graphic
ps – Postscript document
swf – Macromedia Flash Format File
ps – Postscript document bmp – Windows bitmap
gif – Compuserve graphics interchange
jpg – JPEG compliant image
thumbnail – Thumbnail image
tiff – Tagged image file format
rtf – Rich Text Format doc – Microsoft Word Document
pcx – Paintbrush Bitmap Image
png – Portable Network Graphic
ps – Postscript document
txt – Text document
xls – Microsoft Excel Spreadsheet csv – Comma Separated Values
html – Hypertext Markup Language
mdb – Microsoft Access Database
ods – OpenDocument spreadsheet
pcx – Graphics format
pdf – Portable Document Format
ps – Postscript document
rtf – Rich text format
xml – Extensible Markup Language

Image formats

CONVERT FROM                                                         TO

bmp – Windows bitmap gif – Compuserve graphics interchange
ico – Windows Icon
jpg – JPEG compliant image
pcx – PC Paintbrush Bitmap Graphic
ps – Postscript document
png – Portable Network Graphic
tga – Truevision Targa Graphic
thumbnail – Thumbnail image
tiff – Tagged image file format
wbmp – Wireless Bitmap File Format
gif – Compuserve graphics interchange bmp – Windows bitmap
jpg – JPEG compliant image
pcx – PC Paintbrush Bitmap Graphic
ps – Postscript document
png – Portable Network Graphic
tga – Truevision Targa Graphic
thumbnail – Thumbnail image
tiff – Tagged image file format
wbmp – Wireless Bitmap File Format
jpg – JPEG compliant image bmp – Windows bitmap
gif – Compuserve graphics interchange
ico – Windows Icon
pcx – PC Paintbrush Bitmap Graphic
ps – Postscript document
png – Portable Network Graphic
tga – Truevision Targa Graphic
thumbnail – Thumbnail image
tiff – Tagged image file format
wbmp – Wireless Bitmap File Format
pcx – PC Paintbrush Bitmap Graphic bmp – Windows bitmap
gif – Compuserve graphics interchange
ico – Windows Icon
jpg – JPEG compliant image
ps – Postscript document
png – Portable Network Graphic
tga – Truevision Targa Graphic
thumbnail – Thumbnail image
tiff – Tagged image file format
wbmp – Wireless Bitmap File Format
png – Portable Network Graphic bmp – Windows bitmap
gif – Compuserve graphics interchange
ico – Windows Icon
jpg – JPEG compliant image
ps – Postscript document
pcx – PC Paintbrush Bitmap Graphic
tga – Truevision Targa Graphic
thumbnail – Thumbnail image
tiff – Tagged image file format
wbmp – Wireless Bitmap File Format
tga – Truevision Targa Graphic bmp – Windows bitmap
gif – Compuserve graphics interchange
ico – Windows Icon
jpg – JPEG compliant image
ps – Postscript document
pcx – PC Paintbrush Bitmap Graphic
png – Portable Network Graphic
thumbnail – Thumbnail image
tiff – Tagged image file format
wbmp – Wireless Bitmap File Format
tiff – Tagged image file format bmp – Windows bitmap
gif – Compuserve graphics interchange
ico – Windows Icon
jpg – JPEG compliant image
pcx – PC Paintbrush Bitmap Graphic
ps – Postscript document
png – Portable Network Graphic
tga – Truevision Targa Graphic
thumbnail – Thumbnail image
wbmp – Wireless Bitmap File Format
wbmp – Wireless Bitmap File Format bmp – Windows bitmap
gif – Compuserve graphics interchange
ico – Windows Icon
jpg – JPEG compliant image
ps – Postscript document
pcx – PC Paintbrush Bitmap Graphic
png – Portable Network Graphic
tga – Truevision Targa Graphic
thumbnail – Thumbnail image
tiff – Tagged image file format

Music Formats

CONVERT FROM                                                         TO

aac – Advanced Audio Coding File ac3 – AC3 Audio File
amr – Adaptive Multi-Rate ACELP Codec
flac – Free Lossless Audio Codec
m4a – MPEG-4 Video File
mp3 – Compressed audio file
mp4 – MPEG-4 Video File
ogg – Ogg Vorbis Compressed Audio File
wav – Windows audio file
wma – Windows media file
ac3 – AC3 Audio File aac – Advanced Audio Coding File
mp3 – Compressed audio file
m4a – Compressed video file
ogg – Ogg Vorbis Compressed Audio File
wav – Windows audio file
flac – Free Lossless Audio Codec aac – Advanced Audio Coding File
ac3 – AC3 Audio File
mp3 – Compressed audio file
m4a – Compressed video file
ogg – Ogg Vorbis Compressed Audio File
wav – Windows audio file
m4a – Compressed video file aac – Advanced Audio Coding File
ac3 – AC3 Audio File
amr – Adaptive Multi-Rate ACELP Codec
flac – Free Lossless Audio Codec
mp3 – Compressed audio file
mp4 – MPEG-4 Video File
ogg – Ogg Vorbis Compressed Audio File
wav – Windows audio file
wma – Windows media file
mp3 – Compressed audio file aac – Advanced Audio Coding File
ac3 – AC3 Audio File
amr – Adaptive Multi-Rate ACELP Codec
flac – Free Lossless Audio Codec
m4a – MPEG-4 Video File
mp4 – MPEG-4 Video File
ogg – Ogg Vorbis Compressed Audio File
wav – Windows audio file
wma – Windows media file
ra – RealMedia Streaming Media aac – Advanced Audio Coding File
ac3 – AC3 Audio File
amr – Adaptive Multi-Rate ACELP Codec
flac – Free Lossless Audio Codec
m4a – MPEG-4 Video File
mp3 – Compressed audio file
mp4 – MPEG-4 Video File
ogg – Ogg Vorbis Compressed Audio File
wav – Windows audio file
wma – Windows media file
ram – RealMedia Metafile aac – Advanced Audio Coding File
ac3 – AC3 Audio File
amr – Adaptive Multi-Rate ACELP Codec
flac – Free Lossless Audio Codec
m4a – MPEG-4 Video File
mp3 – Compressed audio file
mp4 – MPEG-4 Video File
ogg – Ogg Vorbis Compressed Audio File
wav – Windows audio file
wma – Windows media file
wav – Windows audio file aac – Advanced Audio Coding File
ac3 – AC3 Audio File
amr – Adaptive Multi-Rate ACELP Codec
flac – Free Lossless Audio Codec
m4a – MPEG-4 Video File
mp3 – Compressed audio file
mp4 – MPEG-4 Video File
ogg – Ogg Vorbis Compressed Audio File
wav – Windows audio file
wma – Windows media file
wma – Windows media file aac – Advanced Audio Coding File
m4a – Compressed video file
mp3 – Compressed audio file
mp4 – MPEG-4 Video File
ogg – Ogg Vorbis Compressed Audio File
wav – Windows audio file

Video Formats

CONVERT FROM                                                         TO

3gp – 3GPP Multimedia File aac – Advanced Audio Coding File
ac3 – AC3 Audio File
amr – Adaptive Multi-Rate ACELP Codec
avi – Windows video file
flac – Free Lossless Audio Codec
flv – Flash Video
ipod – MPEG-4 Video File
mov – Apple QuickTime Movie
mp3 – Compressed audio file
mp4 – MPEG-4 Video File
mpg – Moving Picture Experts Group File
ogg – Ogg Vorbis Compressed Audio File
wav – Windows audio file
avi – Windows video file 3gp – 3GPP Multimedia File
aac – Advanced Audio Coding File
ac3 – AC3 Audio File
amr – Adaptive Multi-Rate ACELP Codec
flac – Free Lossless Audio Codec
flv – Flash Video
gif – Graphic Interchange Format
mov – Apple QuickTime Movie
mp3 – Compressed audio file
mp4 – MPEG-4 Video File
mpg – Moving Picture Experts Group File
ogg – Ogg Vorbis Compressed Audio File
wav – Windows audio file
flv – Flash video 3gp – 3GPP Multimedia File
aac – Advanced Audio Coding File
ac3 – AC3 Audio File
avi – Windows video file
flac – Free Lossless Audio Codec
gif – Graphic Interchange Format
mov – Apple QuickTime Movie
mp3 – Compressed audio file
mp4 – MPEG-4 Video File
mpg – Moving Picture Experts Group File
ogg – Ogg Vorbis Compressed Audio File
wav – Windows audio file
gvi – Google video file aac – Advanced Audio Coding File
avi – Windows video file
flv – Flash Video
gif – Graphic Interchange Format
mov – Apple QuickTime Movie
mp3 – Compressed audio file
mp4 – MPEG-4 Video File
mpg – Moving Picture Experts Group File
ogg – Ogg Vorbis Compressed Audio File
wav – Windows audio file
m4v – MPEG-4 Video File 3gp – 3GPP Multimedia File
aac – Advanced Audio Coding File
ac3 – AC3 Audio File
avi – Windows video file
flac – Free Lossless Audio Codec
flv – Flash Video
gif – Graphic Interchange Format
mov – Apple QuickTime Movie
mp3 – Compressed audio file
mp4 – MPEG-4 Video File
mpg – Moving Picture Experts Group File
ogg – Ogg Vorbis Compressed Audio File
wav – Windows audio file
mov – Apple QuickTime Movie 3gp – 3GPP Multimedia File
aac – Advanced Audio Coding File
ac3 – AC3 Audio File
avi – Windows video file
flv – Flash Video
gif – Graphic Interchange Format
mp3 – Compressed audio file
mp4 – MPEG-4 Video File
mpg – Moving Picture Experts Group File
ogg – Ogg Vorbis Compressed Audio File
wav – Windows audio file
mp4 – MPEG-4 Video File 3gp – 3GPP Multimedia File
aac – Advanced Audio Coding File
ac3 – AC3 Audio File
avi – Windows video file
flac – Free Lossless Audio Codec
flv – Flash Video
gif – Graphic Interchange Format
mov – Apple QuickTime Movie
mp3 – Compressed audio file
mpg – Moving Picture Experts Group File
ogg – Ogg Vorbis Compressed Audio File
wav – Windows audio file
mpg – Moving Picture Experts Group File 3gp – 3GPP Multimedia File
aac – Advanced Audio Coding File
ac3 – AC3 Audio File
amr – Adaptive Multi-Rate ACELP Codec
avi – Windows video file
flac – Free Lossless Audio Codec
flv – Flash Video
mov – Apple QuickTime Movie
mp3 – Compressed audio file
mp4 – MPEG-4 Video File
ogg – Ogg Vorbis Compressed Audio File
wav – Windows audio file
rm – RealMedia Streaming Media 3gp – 3GPP Multimedia File
aac – Advanced Audio Coding File
ac3 – AC3 Audio File
amr – Adaptive Multi-Rate ACELP Codec
avi – Windows video file
flac – Free Lossless Audio Codec
flv – Flash Video
gif – Graphic Interchange Format
mov – Apple QuickTime Movie
mp3 – Compressed audio file
mp4 – MPEG-4 Video File
mpg – Moving Picture Experts Group File
ogg – Ogg Vorbis Compressed Audio File
wav – Windows audio file
rmvb – RealVideo Variable Bit Rate File 3gp – 3GPP Multimedia File
aac – Advanced Audio Coding File
ac3 – AC3 Audio File
amr – Adaptive Multi-Rate ACELP Codec
avi – Windows video file
flac – Free Lossless Audio Codec
flv – Flash Video
gif – Graphic Interchange Format
mov – Apple QuickTime Movie
mp3 – Compressed audio file
mp4 – MPEG-4 Video File
mpg – Moving Picture Experts Group File
ogg – Ogg Vorbis Compressed Audio File
wav – Windows audio file
vob – DVD Video Movie File 3gp – 3GPP Multimedia File
aac – Advanced Audio Coding File
ac3 – AC3 Audio File
amr – Adaptive Multi-Rate ACELP Codec
avi – Windows video file
flac – Free Lossless Audio Codec
flv – Flash Video
gif – Graphic Interchange Format
mov – Apple QuickTime Movie
mp3 – Compressed audio file
mp4 – MPEG-4 Video File
mpg – Moving Picture Experts Group File
ogg – Ogg Vorbis Compressed Audio File
wav – Windows audio file
wmv – Windows Media Video 3gp – 3GPP Multimedia File
aac – Advanced Audio Coding File
ac3 – AC3 Audio File
amr – Adaptive Multi-Rate ACELP Codec
avi – Windows video file
flac – Free Lossless Audio Codec
flv – Flash Video
ipod – MPEG-4 Video File
mov – Apple QuickTime Movie
mp3 – Compressed audio file
mp4 – MPEG-4 Video File
mpg – Moving Picture Experts Group File
ogg – Ogg Vorbis Compressed Audio File
wav – Windows audio file

Posted in Tools | No Comments »

Refresh ASPX page from a pop up Page

April 29th, 2010 by Nishan

Most of the time systems use pop up box for confirm record update delete. When the user select the options main page need to refresh according to the user action.
But on .Net there is no straight forward way to do this. But using following simple javascript you can do this easily.
Put the following code into you pop up page click event

string strString = “<script language=JavaScript> “;
strString = scriptString + “window.opener.document.forms[0].submit(); </script>”;
if(!Page.IsClientScriptBlockRegistered(scriptString))
{Page.RegisterClientScriptBlock(“script”, scriptString);}

Posted in .net | No Comments »

DataReader VS connection Close

April 29th, 2010 by Nishan

How many of you use the DataReader in you programs and realise if you close the connection you can t use the Datareader as well. Or don t even think about closing the connection at all.

Even though ADO.net works in disconnected architecture not all the controls work in disconnected way.

DataReader is one of them.

Open connections full up your connection pool. Best way to use the connection is, open it when you need and close it once you finish executing the SQL. But if close the connection after the

SqlDataReader dr = cmdAdd.ExecuteReader();

conn.close();

You wont be able to access the datareader as well.

CommandBehavior.CloseConnection can use to do this.

public static SqlDataReader get_All_Sessions(string mSessions)
{
SqlConnection conPortal = new SqlConnection(Framework.common.mconnection.ConnectionString);
SqlCommand cmdAdd = new SqlCommand(“SP_GET_SESSIONS_DT”, conPortal);
cmdAdd.CommandType = CommandType.StoredProcedure;
cmdAdd.Parameters.Add( “@SESS_ID”, mSessions);
conPortal.Open();
SqlDataReader dr = cmdAdd.ExecuteReader(CommandBehavior.CloseConnection);
return dr;
}

If you use the following method you access the datareader. Once you close Datareader connection close itself.

Thanks for janith who told me the this info.

Posted in .net | No Comments »

Windows shortcut keys

April 29th, 2010 by Nishan

Life getting busy. Looking to speed up your busy life. Simple short cuts for your computer activities.

In windows there are shout cut keys to run programs instead of going through the  your list of programs.
Using Windows Key

WINDOWS KEY+E           :   To open the Explorer Window

WINDOWS KEY+M          :   Minimize all open windows

WINDOWS KEY+D           :   Minimize all open window / Open them back

WINDOWS KEY+R           :   Open the run window

WINDOWS KEY+F           :   Open the search window

WINDOWS KEY+L           :   Log Out

ALT+TAB            :   View open windows in a small window

ALT+ESC            :   Switch between open windows

ALT+F4               :   Close Current window

CTRL+A               :    Select All files on a folder (you need to select a one file first)

CTRL+C               :   Copy Files

CTRL+V               :   Paste Files

CTRL+X               :   Cut Files

SHIFT+DELETE   : Delete Files from(don t even goto recycle bin)

F2      :   Rename a folder

F1      :   Help

F3      :   Find

F5      :   Referesh

ALT+ENTER    : Get the size of a folder

PrintScreen        :   Save the screen as an image

Using Run Window

You can launch your favorite

Posted in Windows | No Comments »

Start writing less codes with Postsharp

April 20th, 2010 by Nishan

How many times you write below code on your applications

public void methodName(string friendName)
{
try
{
LogMessage(“AddFriend Called”);
}
catch (Exception ex)
{
LogException(ex);
}
}

You will write the same LogException in all your methods but this is not easy maintain and time consuming. PostSharp helps to clean this mess by encapsulating these aspects as custom attributes.

[Log()]
public void methodName(string friendName){
try{
}
catch (Exception ex){
}
}

Download the framework and start using http://www.sharpcrafters.com/

Posted in .net | No Comments »