This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected void ahrefOut_Click(object sender, EventArgs e) | |
{//Logout button | |
//Get the current absolute URL of the ContentPlaceHolder | |
string AbsoluteURL = BodyContent.Page.Request.Url.AbsoluteUri; | |
//Set the string to search for in the URL | |
string strCheck = "Test"; | |
//If the URL contains (part of) the string to check redirect to special login page |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Option Compare Database | |
Function CleanForm() | |
'Call as CleanForm(), will clear current text & comboboxes on active form. | |
For Each ctl In Form.Controls 'Loop through controls of the form | |
Select Case ctl.ControlType | |
Case acTextBox, acComboBox 'Select Textboxes and Comboboxes (DropDownLists) | |
ctl.value = "" 'Set the value to "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Private Sub ExportSR() | |
1 Dim db As DAO.Database | |
2 Dim rs As DAO.Recordset | |
3 Dim oApp As Excel.Application | |
4 Dim i As Integer | |
5 Dim oWbk As Object | |
6 Dim oWbs As Object | |
7 Set db = CurrentDb() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected void CoalesNull(Object sender, EventArgs e) { | |
string MessageNoNull = "Hello World!"; | |
string ResultNoNull = MessageNoNull ?? "Null!"; | |
Console.WriteLine(ResultNoNull); //Prints "Hello Word!" | |
string MessageNull = null; | |
string ResultNull = MessageNull ?? "Null!"; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected void btnLINQ_Click(object sender, EventArgs e) | |
{ | |
string[] WordsToUse = { "Hello ", "World", "!" }; //Array of words to use | |
var Res = WordsToUse.Aggregate((current, next) => current + next); //Aggregate words using LINQ | |
System.Web.UI.ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "AlertBox", "alert('" + Res + "');", true); //Print text using JavaScript (don't use in production) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub ReadPDF() | |
'NOTE: Adobe Acrobat Pro XI or higher has to be installed and the following references have to be active: | |
'Adobe Acrobat 10.0 Type Library (acrobat.tlb) Usually found in: C:\Program Files (x86)\Adobe\Acrobat 11.0\Acrobat\ | |
'Acrobat Access 3.0 Type Library (Accessibility.api) Usually found in: C:\Program Files (x86)\Adobe\Acrobat 11.0\Acrobat\plug_ins\ | |
'To check for active references, see Tools -> References OR use the Immediate window (ctrl + G) and type "for each r in references : debug.Print r.name, r.fullpath : next r" (minus "" quotes) | |
Dim AcroApp As Acrobat.CAcroApp 'We're going to use the Acrobat 'app', so point to that | |
Dim theForm As Acrobat.CAcroPDDoc 'Define that we're going to use a Acrobat Form (known as PDF) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected void NullCheck(Object sender, EventArgs e) { | |
/* | |
* Different ways to check for a null value as an example | |
* Assume we have TextBox1 that we want to fill with a value, but only if the string is not null | |
*/ | |
//Set the value that we want to use | |
string NewMessage = null; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void ActivateGrid() | |
{ | |
try | |
{ | |
string conStr = ConfigurationManager.ConnectionStrings["dbConnectionString"].ConnectionString; | |
MySqlConnection con = new MySqlConnection(conStr); //Set a new connection | |
con.Open(); //Open the connection | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Void that generates a random number | |
//Call by using RandomInt(0, 100) where 0 is the minimum number and 100 the max | |
public static int GetRandom { get; set; } | |
void RandomInt(int MinRandom, int MaxRandom) | |
{ | |
Random r = new Random(); | |
GetRandom = r.Next(MinRandom, MaxRandom); | |
} |
OlderNewer