SoFunction
Updated on 2025-03-07

C# background output javascript statement sample program


using System;
using ;
using ;
using ;
using ;

namespace MyOraComm
{
/// <summary>
/// Summary description of FuncTion.
/// </summary>
public class Function
{
  public Function()
  {
   //
// TODO: Add constructor logic here
   //
  }
  // ====== ==============================================================================
//================================================================================
  //=======================================================================================
#region The javascript dialog box pops up, whether it returns or ends.
  public void WriteMessage(string strMsg,bool Back,bool End)
  {
   HttpContext Context=;
   strMsg=("'","");
   strMsg=("/r/n","");
   if(strMsg!=""&&strMsg!=null)
    ("<script language=javascript>alert('"+strMsg+"');</script>");
   if(Back)
    ("<script language=javascript>();</script>");
   if(End)
    ();
  }
  #endregion

#region Write the content of the javascript statement, <script language=javascript></script> has been written.
  public void WriteJavaScript(string strJavaScript)
  {
   HttpContext Context=;
   ("<script language=javascript>"+strJavaScript+"</script>");
  }
  #endregion

#region Close the current page
  public void CloseWindow()
  {
   HttpContext Context=;
   ("<script language=javascript>();</script>");
   ();
  }
  #endregion

  //====================================================================================
//==========================================================================================
  //=====================================================================================

#region is implemented using regular expressions. Verify whether the input is a number
  public bool IsValidNumer(string str)
  {
    reg1
    = new (@"^[-]?/d+[.]?/d*$");
   return (str);
  }
  #endregion

#region Verify whether it is a decimal
  public bool IsValidDecimal(string str)
  {
   return (str,@"[0]./d{1,2}|[1]");
  }

  #endregion

#region Verify email address
  public bool IsValidEmail(string strIn)
  {
   // Return true if strIn is in valid e-mail format.
   return (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's date form replaces mm/dd/yy's date form.
  public string MDYToDMY(String input)
  {
   return (input,"//b(?//d{1,2})/(?//d{1,2})/(?//d{2,4})//b","${day}-${month}-${year}");
  }
  #endregion

#region Verify whether it is a phone number
  public bool IsValidTelNum(string strIn)
  {
   return (strIn,@"(/d+-)?(/d{4}-?/d{7}|/d{3}-?/d{8}|^/d{7,8})(-/d+)?");
  }
  #endregion

#region Verification year, month, day
  bool IsValidDate(string strIn)
  {
   return (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 suffix name
  bool IsValidPostfix(string strIn)
  {
   return (strIn,@"/.(?i:gif|jpg)$");
  }
  #endregion

#region Verify whether the characters are between 4 and 12
  bool IsValidByte(string strIn)
  {
   return (strIn,@"^[a-z]{4,12}$");
  }
  #endregion

#region Verify IP
  bool IsValidIp(string strIn)
  {
   return (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
}
}