ASP.NET Webforms: Detect postback on client-side

As JavaScript has no concept of postback, one way to achieve this would as follows:

VB backend code (on Page_Load)

ScriptManager.RegisterStartupScript(Me, Me.GetType(), "isPostBack", String.Format("var isPostback = {0};", IsPostBack.ToString().ToLower()), True)

 

Javascript frontend (I put it under doc ready)

$(document).ready(function () {
   if(isPostback) {
        // Postback specific logic here
    }
);}

 

 

Reset identity seed after deleting records in SQL Server

If you need to reset the identity seed after deleting a record/records, you can use the following statement where the last INT value ( eg: 20 below), stands for the row from which you want to reseed from. This would be the last row in the table after deleting the records you want to.

DBCC CHECKIDENT ('Tablename', RESEED, 20);
GO

Once you run this, the next entered column will have the identity value ’21’

Visual Studio 2017 | Start every solution from the jump list as Administrator

Even if you add the setting to start VS2017 as ad Administrator, it doesn’t do that when accessing solutions from the jump list. To get that going, you need to add a registry key, which is fairly straightforward.

Due to WordPress security reasons, I can’t upload the file here, so just go ahead and create a Registration Entries file (.reg) using the content below and run it as admin… simple!

NOTE: For x64 and other versions of Visual Studio, modify the path name accordingly.

Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers]
"C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Professional\\Common7\\IDE\\devenv.exe"="~ RUNASADMIN"

 

Shutdown timer on Windows desktop

Create a shutdown timer for Windows

To create a shutdown timer manually, open Command Prompt and type the command shutdown -s -t XXXX. The “XXXX” should be the time in seconds you want to elapse before the computer shuts down. For instance, if you want the computer to shut down in 2 hours, the command should look like shutdown -s -t 7200.

If you want to restart your computer on a delay, use shutdown -r -t XXXX instead.

To cancel the timer, open the Run window or Command Prompt again and enter shutdown -a.

Create a shutdown timer shortcut

If you need to use a shutdown timer regularly, you can take this trick one step further by turning it into a desktop shortcut.

shutdown-timer-windows-shortcut.png
  • Right-click on the desktop, hover over New and select Shortcut in the side menu.
  • In the path field type “shutdown -s -t XXXX” and click Next.
  • Enter a name for the shortcut (for example, “Shutdown 1 Hour”) and click Finish.

Any time you double-click the shutdown shortcut, the timer will start. To cancel the timer, you can create a second shortcut using shutdown -a or enter the shutdown -a command in Command Prompt.

To change the time on the shutdown timer, right-click the shortcut icon, select Properties and change the seconds value in the Target field. From within Properties, you can also assign a different image as the icon.