---------
/* Get Machine Name (MachineName)*/
string MchName=System.Environment.MachineName.ToString();
/* Get Operation System (OSVersion)*/
string OsVersion = System.Environment.OSVersion.ToString();
/* Get Machine UserName (UserName)*/
string UName = System.Environment.UserName.ToString();
-------
/* SharePoint Tutorial */
http://www.deitel.com/ResourceCenters/Software/SharePoint/Tutorials/tabid/2783/Default.aspx
________
http://www.queness.com/post/356/create-a-vertical-horizontal-and-diagonal-sliding-content-website-with-jquery
_________________
File upload
--------
try
{
if (Updfile.FileName.Length > 0)
{
a = Updfile.FileName.Split('.');
fileName = Convert.ToString(System.DateTime.Now.Ticks) + "." + a.GetValue(1).ToString();
FilePath = Server.MapPath(@"~\MDAFile");
Updfile.SaveAs(FilePath + @"\" + fileName);
//if (strMode == "EDIT")
//{
// File.Delete(FilePath + @"\" + hdFile.Value);
//}
}
else
{
fileName = hdFile.Value;
}
}
catch
{
fileName = hdFile.Value;
}
___________________________
Work Log
1.Enable auto post back to work in selected index change.
2.Session: Session["Mode"] = "0";
Why use Sp?
a. It works/executes fast as it is in precompiled mode.
b. As it is in the database so if the BL gets leaked there is no chance of leaking the database… so security..
Query String..
Put this code to your submit button event handler.
private void btnSubmit_Click(object sender, System.EventArgs e)
{
Response.Redirect("Webform2.aspx?Name=" +
this.txtName.Text + "&LastName=" +
this.txtLastName.Text);
}
Put this code to second page page_load.
private void Page_Load(object sender, System.EventArgs e)
{
this.txtBox1.Text = Request.QueryString["Name"];
this.txtBox2.Text = Request.QueryString["LastName"];
}
To view a date in a gridview frm table.
To fetch a int data from a gridview select event….
Convert.ToInt32(gvEmp.SelectedRow.Cells[1].Text);
RegEx
Numeric- “\d+\.?\d*”
Email- "\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
Fileuploader=".*(\.txt|\.TXT)$"
String
String two =3D "12";
Int one =3D int.Parse(two.Substring(0,1));
Int two =3D int.Parse(two.Substring(1,1));
Int both =3D int.Parse(two.Substring(0,2));
Work with date time
DateTime tmp=Convert.ToDateTime(dr.ItemArray.GetValue(2));
txtYear.Text = tmp.Year.ToString();
ddlDay.SelectedIndex = Convert.ToInt32(tmp.Day.ToString())-1;
ddlMonth.SelectedIndex = Convert.ToInt32(tmp.Month.ToString()-1);
Using the Regex Class
Add a using statement to reference the System.Text.RegularExpressions namespace.
Call the IsMatch method of the Regex class, as shown in the following example.
// Instance method:
Regex reg = new Regex(@"^[a-zA-Z'.]{1,40}$");
Response.Write(reg.IsMatch(txtName.Text));
// Static method:
if (!Regex.IsMatch(txtName.Text,
@"^[a-zA-Z'.]{1,40}$"))
{
// Name does not match schema
}
Making a CheckAll functionality
To add a check-all functionality in the GridView, simply add a HTML CheckBox to the header template of the checkbox column.
runat="server" type="checkbox" />
SelectAllCheckboxes JavaScript method:
Show Data in formated way data [format{0:dd-MMM-yyyy}] in greidview
Declare a boolean column
CAST('True' AS bit) AS L
Regex for 0, decimal, integer…
^[0-9.\d+]{1,40}$
GET GRIDVIEW ROW
GridViewRow row = (GridViewRow)((Control)e.CommandSource).NamingContainer;
int CustId = Convert.ToInt32(GvDisp.DataKeys[row.RowIndex].Value.ToString());
OFFLINE DATATABLE SORTING AND SAVING
dataview v=dt.defaultview;
v.sort="columnName DESC";
dt=v.toTable();
TRY CATCH IN SQL SERVER
BEGIN TRY
BEGIN TRAN
SELECT * FROM Advertisement
COMMIT TRANSACTION
END TRY
BEGIN CATCH
SELECT ERROR_NUMBER() ErrorNBR, ERROR_SEVERITY() Severity,
ERROR_LINE () ErrorLine, ERROR_MESSAGE() Msg
ROLLBACK TRANSACTION
END CATCH
Getting password in edit
txtPassword.Text = ManagePassword.strDecrypt(objUsr.Password, "vtpl2006", "vtpl2009");
ViewState["MyPassword"] = txtPassword.Text;
txtPassword.Attributes.Add("value", ViewState["MyPassword"].ToString());
lblPrice.Text = String.Format("{0:c}", price);
lblTime.Text = String.Format("{0:T}", rightNow);
lblDate.Text = String.Format("{0:d}", rightNow);
lblBigInt.Text = String.Format("{0:#,###}", bigNumber);
For editing a password field
txtPassword.Text = ManagePassword.strDecrypt(objUsr.Password, "vtpl2006", "vtpl2009");
ViewState["MyPassword"] = txtPassword.Text;
txtPassword.Attributes.Add("value", ViewState["MyPassword"].ToString());
public string ConvertSize ( decimal ip )
{
decimal op = ip / 1024;
string strUnit = "";
if ( ip >= 1073741824 )
{
op = ip / 1073741824;
strUnit = "GB";
}
else if ( ip >= 1048576 )
{
op = Convert.ToDecimal ( ip / 1048576 );
strUnit = "MB";
}
else if ( ip >= 1024 )
{
op = Convert.ToDecimal ( ip / 1024 );
strUnit = "KB";
}
else if ( ip > 0 )
{
op = ip;
strUnit = "Bytes";
}
else
{
op = 0.00M;
strUnit = "0";
}
return op.ToString (
SEND MAIL
public void ExecuteHtmlSendMail(string FromAddress, string ToAddress, string BodyText, string Subject)
{
MailMessage mailMsg = new MailMessage();
mailMsg.From = new MailAddress(FromAddress);
mailMsg.To.Add(new MailAddress(ToAddress));
mailMsg.Subject = Subject;
mailMsg.BodyEncoding = System.Text.Encoding.GetEncoding(”utf-8?);
System.Net.Mail.AlternateView plainView = System.Net.Mail.AlternateView.CreateAlternateViewFromString
(System.Text.RegularExpressions.Regex.Replace(BodyText, @”<(.|\n)*?>”, string.Empty), null, “text/plain”);
System.Net.Mail.AlternateView htmlView = System.Net.Mail.AlternateView.CreateAlternateViewFromString(BodyText, null, “text/html”);
mailMsg.AlternateViews.Add(plainView);
mailMsg.AlternateViews.Add(htmlView);
// Smtp configuration
SmtpClient smtp = new SmtpClient();
smtp.Host = “smtp.gmail.com”;
smtp.Credentials = new System.Net.NetworkCredential(”username”, “password”);
smtp.EnableSsl = true;
smtp.Send(mailMsg);
}
Read Word Doc
protected void Page_Load(object sender, EventArgs e)
{
Microsoft.Office.Interop.Word.ApplicationClass wordApp = new Microsoft.Office.Interop.Word.ApplicationClass();
object file = "D:\\test1.doc"; // Specify path for word file
object nullobj = System.Reflection.Missing.Value;
Microsoft.Office.Interop.Word.Document doc = wordApp.Documents.Open(ref file, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj, ref nullobj);
Microsoft.Office.Interop.Word.Document doc1 = wordApp.ActiveDocument;
string mContent = doc1.Content.Text;
Response.Write(mContent);
}
Message Show
System.Web.UI.ScriptManager.RegisterClientScriptBlock(Page, typeof(PagerButtons), "Session Timeout", "alert('Your active session has been expired please login again')", true);
GET PRIVIOUS PAGE NAME
System.IO.Path.GetFileName(Request.ServerVariables["HTTP_REFERER"]) == "inbox_interests.aspx"
JAVASCRIPT NEW WINDOW
','','width=400,height=250,status=no,location=no,menubar=no,%20left=0,%20top=0,%20scrollbars=1');%20%20sub.parent.history.back();">
Javascript Message
With update panel
ScriptManager.RegisterStartupScript(this, this.GetType(), "alertScript",
"alert('Registration Successfull')", true);
Without update panel
Page.ClientScript.RegisterStartupScript(this,this.GetType(), "alert", "alert('Registration Successfull')", true);
Return data from SP
SqlConnection conn=new SqlConnection();
conn.ConnectionString = @"Data Source=SERVER1\SQLEXPRESS;Initial Catalog=MarryAnNri;Persist Security Info=True;User ID=sa;Password=sa@1234;connection timeout = 2000";
SqlCommand cmd=new SqlCommand("spTest",conn);
SqlDataAdapter da=new SqlDataAdapter();
da.SelectCommand = cmd;
DataSet ds=new DataSet();
da.Fill(ds);
__________________
/* Show different type of icon in grid view button */
DataView dv = new DataView();
vw_favourite objFav = new vw_favourite();
objFav.SqlLoad("select * from vw_favourite where UserId='" + ((UserDetails)Session["LoggedUserDetails"]).ID + "'");
dv = objFav.DefaultView;
GVFavourite.DataSource = dv;
GVFavourite.DataBind();
foreach (GridViewRow row in GVFavourite.Rows)
{
Label lbl = (Label)row.FindControl("lbl");
Image img = (Image)row.FindControl("imgBtn");
string filename = lbl.Text;
string ext = filename.Substring(filename.Length - 3);
if ( ext.ToLower() == "txt")
{
img.ImageUrl = "~/images/txt.png";//E:\LinearTech\images
}
else if (ext.ToLower() == "pdf")
{
img.ImageUrl = "~/images/pdf.jpg";
}
else if (ext.ToLower() == "doc")
{
img.ImageUrl = "~/images/doc_icon.jpg";
}
___________________________--
/* Graph Charts */
http://www.codeproject.com/KB/web-image/ZedGraphWebAp1.aspx
__________________
/* Mailing and SMS systems */
http://www.codeproject.com/KB/aspnet/EasySMTP_package.aspx
http://www.aspfree.com/c/a/ASP.NET/Creating-Your-Own-Online-Email-System-in-ASP-NET-2-0/
_________________
|
---------- search page----------------
---------------- google adsence---------------------
________________________
/* Charts , barchart, piechart */
http://www.amcharts.com/download
____________
/* Invoice Format */
http://www.vertex42.com/ExcelTemplates/excel-invoice-template.html
_____________
______________
/* Solving of IIS problem */
http://www.west-wind.com/weblog/posts/698097.aspx
_____________
/* important JavaScript */
http://www.dotnetspider.com/resources/Category545.aspx
______________
/* All column names with table name in another table */
/* It saves every column name with table name in dbo.translations, a new table */
SELECT t.name AS tableName,
SCHEMA_NAME(schema_id) AS [schema],
c.name AS columnName,
CAST(null as varchar(200)) as translation into dbo.translations
FROM sys.tables AS t
INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID
ORDER BY tableName
________________
What are the differences between stored procedure and functions in SQL Server 2000?
Answer
1) functions are used for computations where as procedures
can be used for performing business logic
2) functions MUST return a value, procedures need not be.
3) you can have DML(insert, update, delete) statements in a
function. But, you cannot call such a function in a SQL
query..eg: suppose, if u have a function that is updating a
table.. you can't call that function in any sql query.-
select myFunction(field) from sometable; will throw error.
4) function parameters are always IN, no OUT is possible
5) EXEC command can't be used inside a Function where it
can be used inside an sproc
_____________
/* SharePoint Tutorial */
http://www.deitel.com/ResourceCenters/Software/SharePoint/Tutorials/tabid/2783/Default.aspx
__________
http://forums.asp.net/p/1209470/2126993.aspx
---------------------------------------
WatermarkText="Type First Name Here"
WatermarkCssClass="watermarked" />
----------------------------------
http://www.codeproject.com/KB/aspnet/SendingSMS.aspx
http://forums.asp.net/t/1191703.aspx
--------------------------------
/* Regular Expressions */
ErrorMessage="ID must be 6-10 letters."
ValidationExpression="[a-zA-Z]{6,10}" />
-----------------------------------
ErrorMessage="Password must contain one of @#$%^&*/."
ValidationExpression=".*[@#$%^&*/].*" />
ErrorMessage="Password must be 4-12 nonblank characters."
ValidationExpression="[^\s]{4,12}" />
------------------------
/* Google absence */
http://ctrlf5.net/?p=159
______________________________
/* Custom Control */
/* Scheduler, Gantt Chart */
http://www.codeproject.com/KB/custom-controls/schedule.aspx
http://demos.telerik.com/aspnet-ajax/scheduler/examples/webservice/defaultcs.aspx
___________________
/* Youtube */
____________________
/* Restricat max entry in textbox using javascript */ /* max length in textbox */
/* in aspx */
/* If under master page then just after the first line of Contentplaceholder */
/* In the Code behind */
/* UnderPageload event */
protected void Page_Load(object sender, EventArgs e)
{
//Response.AppendHeader("Refresh", Convert.ToString((Session.Timeout * 60) + 10) + "; url=login.aspx");
Txtsms.Attributes.Add("onkeypress", "CountCharactersGeneral('" + Txtsms.ClientID + "','" + LblChar.ClientID + "'," + 160 + ")");
Txtsms.Attributes.Add("onkeyup", "CountCharactersGeneral('" + Txtsms.ClientID + "','" + LblChar.ClientID + "'," + 160 + ")");
Txtsms.Attributes.Add("onkeydown", "CountCharactersGeneral('" + Txtsms.ClientID + "','" + LblChar.ClientID + "'," + 160 + ")");
Txtsms.Attributes.Add("onPaste", "CountCharactersGeneral('" + Txtsms.ClientID + "','" + LblChar.ClientID + "'," + 160 + ")");
Txtsms.Attributes.Add("onClick", "CountCharactersGeneral('" + Txtsms.ClientID + "','" + LblChar.ClientID + "'," + 160 + ")");
}
______________________________
-----------------------------------
Serial in Gridview
-----------------------
<%# ((GridViewRow)Container).RowIndex + 1%>
__________________________________________
http://en.csharp-online.net/CSharp_Code_Snippets
http://en.csharp-online.net/Category:CSharp_Code_Snippets
Displays whether a computer is 16 or 32 bit
------------------------------------------
If Request.Browser.Win16 = True Then
Response.Write("Win16")
End If
If Request.Browser.Win32 = True Then
Response.Write("Win32")
End If
_______________________________________________
ActiveX controls supported
--------------------------
If Request.Browser.ActiveXControls = True Then
Response.Write("This browser supports Active X Controls")
End If
_____________________________________________
AOL supported
--------------
Is AOL present
If Request.Browser.AOL = True Then
Response.Write("This is an AOL Browser")
End If
______________________________
Background sound supported
---------------------------
If Request.Browser.BackgroundSounds = True Then
Response.Write(" Background Sounds supported ")
End If
_______________________________
Displays the platform (operating system)
--------------------------------
Response.Write(Request.Browser.Platform
____________________________
/* Play Video using asp.net */
BY Using Interop you can acheive this by following three methods,
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.Media;
using WMPLib; //Add this COM Component Reference to your project
public partial class Play : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnPlay_Click(object sender, EventArgs e)
{
string _path = "Your File Path";
//Method 1 using sound player class
SoundPlayer _sm = new SoundPlayer(_path);
_sm.Play();
//Method 2
Microsoft.VisualBasic.Devices.Audio _mvda = new Microsoft.VisualBasic.Devices.Audio();
_mvda.Play(_path, Microsoft.VisualBasic.AudioPlayMode.Background);
//Method 3 using WindowsMediaPlayer Class
WindowsMediaPlayerClass _wmpc = new WindowsMediaPlayerClass();
_wmpc.openPlayer(_path);
_wmpc.play();
}
}
_____________________________________
/* Play video */
http://msdn.microsoft.com/en-us/library/bb324497%28VS.85%29.aspx
http://www.c-sharpcorner.com/uploadfile/scottlysle/csharpwebvideo04212007133218pm/csharpwebvideo.aspx
http://www.dreamincode.net/forums/topic/96169-how-to-programatically-play-a-video/
http://ramcrishna.blogspot.com/2008/09/playing-videos-like-youtube-and.html
OR
BY Using Interop you can acheive this by following three methods,
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.Media;
using WMPLib; //Add this COM Component Reference to your project
public partial class Play : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnPlay_Click(object sender, EventArgs e)
{
string _path = "Your File Path";
//Method 1 using sound player class
SoundPlayer _sm = new SoundPlayer(_path);
_sm.Play();
//Method 2
Microsoft.VisualBasic.Devices.Audio _mvda = new Microsoft.VisualBasic.Devices.Audio();
_mvda.Play(_path, Microsoft.VisualBasic.AudioPlayMode.Background);
//Method 3 using WindowsMediaPlayer Class
WindowsMediaPlayerClass _wmpc = new WindowsMediaPlayerClass();
_wmpc.openPlayer(_path);
_wmpc.play();
__________________________________
/* Media player control with asp.net */
http://www.beansoftware.com/free-asp.net-controls/asp.net-media-player-control.aspx
_________________________________________
/* Water mark in textbox */
______________________________________-
/* Convert to PDF from C# */
Response.AddHeader("content-type", "application/pdf");
Response.AddHeader("Content-Disposition",
"attachment; filename=result.pdf");
_______________________________--
/* Dynamically change web.config dbconnection */
Code Starts Here
Dim myConfiguration As Configuration = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~")
myConfiguration.ConnectionStrings.ConnectionStrings("myDatabaseName").ConnectionString = txtConnectionString.Text
myConfiguration.AppSettings.Settings.Item("myKey").Value = txtmyKey.Text
myConfiguration.Save()
' Code Ends Here
-----------------
We are going to test another variable that we'll declare in the
http://www.highoncoding.com/Articles/119_Writing_in_Web_config_file_dynamically.aspx
_________________________________
Response.Redirect(Page.Request["Redirect"].ToString());
________________________________
/***** Page Time Out **************/
Page.ClientScript.RegisterStartupScript(Me.GetType(),"refresh","window.setTimeout('var url = window.location.href;window.location.href = url',1000);",true)
Where 1000 is in milliseconds ( 1 second)
__________________________________
/***** Video Download *******/
http://www.traincert.net/Default.aspx?tabid=82
http://www.asp.net/learn/
__________________________________
/****** Crystal Report ***********/
http://www.developers.net/tsearch?searchkeys=asp+net+crystal+report+tutorial
___________________________
/**** International Business ********/
http://books.google.co.in/books?id=hvs0fj7NoK4C&printsec=frontcover&dq=international+business+in+information+Technology&source=bl&ots=IxZuUA58ko&sig=5icNHEr8IwUaDDRQnFIwHHwj_K8&hl=en&ei=aFl6S7yUA8m9rAeCrKD1Dw&sa=X&oi=book_result&ct=result&resnum=6&ved=0CCEQ6AEwBQ#
-___________________________________
/***** Floating Div ********/
http://forums.asp.net/p/969889/1220753.aspx#1220753
_____________________________
/****** Seperate with Comma in DB ************/
select substring (( select ', ' + JRNo from JnMBJobSp where LedNo='JNMB3575' FOR XML path('')), 2,500) as JRNo
____________________________
/************** String cut VVI ************/
http://www.codeproject.com/KB/books/0735616485.aspx
temp = objAgentFormMasterTemp.AgentFormNo;
temp1 = temp.Remove(7);
temp2 = temp1.Remove(0,2);
fNo = (Convert.ToInt64(temp2)+1);
string t = String.Format("{0:00000}", fNo);
________________________________________________
/* Autoid in code */
Select TypeImageName From ResturantImages WHERE
RestuId=3AND Type='1' order by newid()
__________________________________
/* menu */
http://www.likno.com/?gclid=COSE__D0v6ACFclA6wodjDjMTQ
_______________________
/* Place comma in query */
select substring (( select ', ' + JRNo from JnMBJobSp where LedNo='JNMB3575' FOR XML path('')), 2,500) as JRNo
-------
select substring (( select distinct ', ' + AcctDetMob from dbo.AcctDetails inner join dbo.AcctMaster ON dbo.AcctDetails.AcctId = dbo.AcctMaster.AcctId where dbo.AcctMaster.AcctType='ag' FOR XML path('')), 2,500) as AcctDetMob
_______________
/* Date Format */
using C = System.Console;
...
static void Main() {
DateTime dateTime = DateTime.Now;
C.WriteLine ("d = {0:d}", dateTime ); // mm/dd/yyyy
C.WriteLine ("D = {0:D}", dateTime ); // month dd, yyyy
C.WriteLine ("f = {0:f}", dateTime ); // day, month dd, yyyy hh:mm
C.WriteLine ("F = {0:F}", dateTime ); // day, month dd, yyyy HH:mm:ss AM/PM
C.WriteLine ("g = {0:g}", dateTime ); // mm/dd/yyyy HH:mm
C.WriteLine ("G = {0:G}", dateTime ); // mm/dd/yyyy hh:mm:ss
C.WriteLine ("M = {0:M}", dateTime ); // month dd
C.WriteLine ("R = {0:R}", dateTime ); // ddd Month yyyy hh:mm:ss GMT
C.WriteLine ("s = {0:s}", dateTime ); // yyyy-mm-dd hh:mm:ss (Sortable)
C.WriteLine ("t = {0:t}", dateTime ); // hh:mm AM/PM
C.WriteLine ("T = {0:T}", dateTime ); // hh:mm:ss AM/PM
// yyyy-mm-dd hh:mm:ss (Sortable)
C.WriteLine ("u = {0:u}", dateTime );
// day, month dd, yyyy hh:mm:ss AM/PM
C.WriteLine ("U = {0:U}", dateTime );
// month, yyyy (March, 2006)
C.WriteLine ("Y = {0:Y}", dateTime );
C.WriteLine ("Month = " + dateTime.Month); // month number (3)
// day of week name (Friday)
C.WriteLine ("Day Of Week = " + dateTime.DayOfWeek);
// 24 hour time (16:12:11)
C.WriteLine ("Time Of Day = " + dateTime.TimeOfDay);
// (632769991310000000)
C.WriteLine("DateTime.Ticks = " + dateTime.Ticks);
// Ticks are the number of 100 nanosecond intervals since 01/01/0001 12:00am
// Ticks are useful in elapsed time measurement.
}
Date and time formatting example (program output)
d = 3/3/2006
D = Friday, March 03, 2006 f = Friday, March 03, 2006 4:20 PM F = Friday, March 03, 2006 4:20:26 PM g = 3/3/2006 4:20 PM G = 3/3/2006 4:20:26 PM M = March 03 R = Fri, 03 Mar 2006 16:20:26 GMT s = 2006-03-03T16:20:26 t = 4:20 PM T = 4:20:26 PM u = 2006-03-03 16:20:26Z U = Friday, March 03, 2006 10:20:26 PM Y = March, 2006 Month = 3 Day Of Week = Friday Time Of Day = 16:20:26.1406250 DateTime.Ticks = 632769996261406250
_____________________________
/* Database Details (Sqlserver) */
using System.Data;
using System.Data.SqlClient;
...
// Substitute your connection string below in conxString
String conxString =
"Data Source=MYSERVER; Integrated Security=True;";
using (SqlConnection sqlConx = new SqlConnection (conxString))
{
sqlConx.Open();
DataTable tblDatabases = sqlConx.GetSchema ("Databases");
sqlConx.Close();
foreach (DataRow row in tblDatabases.Rows)
{
Console.WriteLine ("Database: " + row["database_name"]);
}
}
__________________
/* Regular Expression (All Numeric or String) */
using System.Text.RegularExpressions;
...
const string ALL_NUMERIC_PATTERN = "[a-z|A-Z]";
static readonly Regex All_Numeric_Regex =
new Regex (ALL_NUMERIC_PATTERN);
static bool AllNumeric ( string inputString )
{
if (All_Numeric_Regex.IsMatch ( inputString ))
{
return false;
}
return true;
}
_________________
/* Age Calculation */
// get the difference in years
int years = DateTime.Now.Year - birthdate.Year;
// subtract another year if we're before the
// birth day in the current year
if (DateTime.Now.Month < birthdate.Month || (DateTime.Now.Month == birthdate.Month && DateTime.Now.Day < birthdate.Day))
years--;
______________________
/* Rounding Decimal (Ceiling and Floor) */
Ceiling and Floor
---------------
decimal result;
result = decimal.Floor(1.2M); // result = 1
result = decimal.Floor(1.9M); // result = 1
result = decimal.Floor(1M); // result = 1
result = decimal.Floor(-1.2M); // result = -2
result = decimal.Floor(-1.9M); // result = -2
result = decimal.Ceiling(1.2M); // result = 2
result = decimal.Ceiling(1.9M); // result = 2
result = decimal.Ceiling(1M); // result = 1
result = decimal.Ceiling(-1.2M); // result = -1
result = decimal.Ceiling(-1.9M); // result = -1
Simple Rounding
----------------
decimal result;
result = decimal.Round(1.2M); // result = 1
result = decimal.Round(1.9M); // result = 2
result = decimal.Round(1M); // result = 1
Rounding to a Specified Number of Decimal Places
-----------------------------------------------
decimal result;
result = decimal.Round(1.2345M, 1); // result = 1.2
result = decimal.Round(1.2345M, 2); // result = 1.23
result = decimal.Round(1.2345M, 3); // result = 1.234
result = decimal.Round(1.25M, 1); // result = 1.2
result = decimal.Round(1.35M, 1); // result = 1.4
Midpoint Rules
---------------
decimal result;
result = decimal.Round(1.5M, MidpointRounding.ToEven); // result = 2
result = decimal.Round(2.5M, MidpointRounding.ToEven); // result = 2
result = decimal.Round(1.5M, MidpointRounding.AwayFromZero); // result = 2
result = decimal.Round(2.5M, MidpointRounding.AwayFromZero); // result = 3
result = decimal.Round(-2.5M, MidpointRounding.AwayFromZero); // result = -3
___________________
Print formats (String Format)
-----------------------------
321543.23 - Currency: {0:c} $321,543.23
321543.23 - Currency with 4 decimals: {0:c4} $321,543.2300
321545 - Decimal: {0:d} 321545
321543.23 - Scientific: {0:e} 3.215432e+005
321543.23 - Fixed: {0:f3} 321543.230
321543.23 - General: {0:g} 321543.23
321543.23 - Number: {0:n} 321,543.23
321543.23 - Number with no decimals: {0:n0} 321,543
321543.23 - Number with 4 decimals: {0:n4} 321,543.2300
321543.23 - Percent: {0:p} 32,154,323.00 %
321543.23 - Percent with no decimals: {0:p0} 32,154,323 %
321543.23 - Percent with 4 decimals: {0:p4} 32,154,323.0000 %
321545 - Hex: {0:x} 4e809
321545 - HexFixed: {0:x8} 0004e809
5/27/2010 8:30:03 AM - Short date: {0:d} 5/27/2010
5/27/2010 8:30:03 AM - Long date: {0:D} Thursday, May 27, 2010
5/27/2010 8:30:03 AM - Full (long date - short time): {0:f} Thursday, May 27, 2010 8:30 AM
5/27/2010 8:30:03 AM - Full (long date - long time): {0:F} Thursday, May 27, 2010 8:30:03 AM
5/27/2010 8:30:03 AM - General (short date - short time): {0:g} 5/27/2010 8:30 AM
5/27/2010 8:30:03 AM - General (short date - long time): {0:G} 5/27/2010 8:30:03 AM
5/27/2010 8:30:03 AM - Month Day: {0:m} May 27
5/27/2010 8:30:03 AM - RFC1123: {0:r} Thu, 27 May 2010 08:30:03 GMT
5/27/2010 8:30:03 AM - Sortable/ISO8601: {0:s} 2010-05-27T08:30:03
5/27/2010 8:30:03 AM - Short time: {0:t} 8:30 AM
5/27/2010 8:30:03 AM - Long time: {T} 8:30:03 AM
5/27/2010 8:30:03 AM - 's' but uses Universal time: {0:u} 2010-05-27 08:30:03Z
5/27/2010 8:30:03 AM - Universal sortable: {0:U} Thursday, May 27, 2010 12:30:03 PM
5/27/2010 8:30:03 AM - Year Month: {0:y} May, 2010
5/27/2010 8:30:03 AM - All Days: {0:d dd ddd dddd} 27 27 Thu Thursday
5/27/2010 8:30:03 AM - All Fractions: {0:f ff fff ffff fffff ffffff} 9 96 966 9663 96638 966384
5/27/2010 8:30:03 AM - All Eras: {0:g gg} A.D. A.D.
5/27/2010 8:30:03 AM - All Hours: {0:h hh H HH} 8 08 8 08
5/27/2010 8:30:03 AM - All Months: {0:M MM MMM MMMM} 5 05 May May
5/27/2010 8:30:03 AM - All Minutes: {0:m mm} 30 30
5/27/2010 8:30:03 AM - All Seconds: {0:s ss sss} 3 03 03
5/27/2010 8:30:03 AM - All AM/PM: {0:t tt ttt} A AM AM
5/27/2010 8:30:03 AM - All Years: {0:y yy yyy} 10 10 2010
5/27/2010 8:30:03 AM - All Timezones: {0:z zz zzz zzzz} -4 -04 -04:00 -04:00
____________________________________________
DB Structure
------------
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=111342
http://www.vkinfotek.com/
____________________________
/* Book */
--------
http://book-online.net/doc/pa/payroll-system-database-schema-diagram/
__________________
/* Get Page Name */
public string GetCurrentPageName()
{
string sPath = System.Web.HttpContext.Current.Request.Url.Absolut ePath;
System.IO.FileInfo oInfo = new System.IO.FileInfo(sPath);
string sRet = oInfo.Name;
return sRet;
}
__________________________
/* Run Calculator */
System.Diagnostics.Process.Start("calc");
________________
/* Read From File */
using System;
namespace PlayingAround {
class ReadAll {
public static void Main(string[] args) {
string contents = System.IO.File.ReadAllText(@"C:\t1");
Console.Out.WriteLine("contents = " + contents);
}
}
}
-------------------
/* Read a file with a single call to sReader.ReadToEnd() using streams */
public static string getFileAsString(string fileName) {
StreamReader sReader = null;
string contents = null;
try {
FileStream fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read);
sReader = new StreamReader(fileStream);
contents = sReader.ReadToEnd();
} finally {
if(sReader != null) {
sReader.Close();
}
}
return contents;
}
------------------------
http://aspalliance.com/141
-------------
/* Upload and Show Image */
/* IMP */
http://www.dotnetheaven.com/UploadFile/rahul4_saxena/Makeyourownalbum06202007015010AM/Makeyourownalbum.aspx
----------------------