c background output javascript statement sample program
- 2020-05-27 06:57:22
- OfStack
using System;
using System.Web;
using System.IO;
using System.Security.Cryptography;
using System.Text.RegularExpressions;
namespace MyOraComm
{
/// <summary>
/// FuncTion A summary of.
/// </summary>
public class Function
{
public Function()
{
//
// TODO: Add the constructor logic here
//
}
// ====== ==============================================================================
//========================= Foreground output statement method ================================
//=======================================================================================
#region The pop-up javascript dialog , Whether to return or end.
public void WriteMessage(string strMsg,bool Back,bool End)
{
HttpContext Context=HttpContext.Current;
strMsg=strMsg.Replace("'","");
strMsg=strMsg.Replace("/r/n","");
if(strMsg!=""&&strMsg!=null)
Context.Response.Write("<script language=javascript>alert('"+strMsg+"');</script>");
if(Back)
Context.Response.Write("<script language=javascript>history.back();</script>");
if(End)
Context.Response.End();
}
#endregion
#region write javascript Content of the statement ,<script language=javascript></script> It's written.
public void WriteJavaScript(string strJavaScript)
{
HttpContext Context=HttpContext.Current;
Context.Response.Write("<script language=javascript>"+strJavaScript+"</script>");
}
#endregion
#region Close the current page
public void CloseWindow()
{
HttpContext Context=HttpContext.Current;
Context.Response.Write("<script language=javascript>window.close();</script>");
Context.Response.End();
}
#endregion
//====================================================================================
//========================= Validation class methods written using regular expressions ================================
//=====================================================================================
#region Using regular expressions . Verify that the input is a number
public bool IsValidNumer(string str)
{
System.Text.RegularExpressions.Regex reg1
= new System.Text.RegularExpressions.Regex(@"^[-]?/d+[.]?/d*$");
return reg1.IsMatch(str);
}
#endregion
#region Verify that it is a decimal
public bool IsValidDecimal(string str)
{
return Regex.IsMatch(str,@"[0]./d{1,2}|[1]");
}
#endregion
#region validation Email address
public bool IsValidEmail(string strIn)
{
// Return true if strIn is in valid e-mail format.
return Regex.IsMatch(strIn, @"^([/w-/.]+)@((/[[0-9]{1,3}/.[0-9]{1,3}/.[0-9]{1,3}/.)|(([/w-]+/.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(/]?)$");
}
#endregion
#region dd-mm-yy Date form instead mm/dd/yy Date format.
public string MDYToDMY(String input)
{
return Regex.Replace(input,"//b(?//d{1,2})/(?//d{1,2})/(?//d{2,4})//b","${day}-${month}-${year}");
}
#endregion
#region Verify that it is a phone number
public bool IsValidTelNum(string strIn)
{
return Regex.IsMatch(strIn,@"(/d+-)?(/d{4}-?/d{7}|/d{3}-?/d{8}|^/d{7,8})(-/d+)?");
}
#endregion
#region Verify year month day
bool IsValidDate(string strIn)
{
return Regex.IsMatch(strIn,@"^2/d{3}-(?:0?[1-9]|1[0-2])-(?:0?[1-9]|[1-2]/d|3[0-1])(?:0?[1-9]|1/d|2[0-3])?:0?[1-9]|[1-5]/d)?:0?[1-9]|[1-5]/d)$");
}
#endregion
#region Verify the suffix name
bool IsValidPostfix(string strIn)
{
return Regex.IsMatch(strIn,@"/.(?i:gif|jpg)$");
}
#endregion
#region Verify that the character is present 4 to 12 between
bool IsValidByte(string strIn)
{
return Regex.IsMatch(strIn,@"^[a-z]{4,12}$");
}
#endregion
#region validation IP
bool IsValidIp(string strIn)
{
return Regex.IsMatch(strIn,@"^(/d{1,2}|1/d/d|2[0-4]/d|25[0-5])/.(/d{1,2}|1/d/d|2[0-4]/d|25[0-5])/.(/d{1,2}|1/d/d|2[0-4]/d|25[0-5])/.(/d{1,2}|1/d/d|2[0-4]/d|25[0-5])$");
}
#endregion
}
}