JavaScript/JQuery – How to retrieve resources translations in JS

In your JS code write you can write the following literal declaration into a JS variable.

var data = “<asp:Literal runat=”server” Text=”<%$Resources:myresourcefile,resourcetitle%>” />”;

Then you can use the value in the data variable to lets say hide something in your page based on a translation. In the following example I hid a certain breadcrumb information based on different languages.

$(“#breadcrumb ul li a:contains(” + code + “)”).hide();

Tips: SQL Server – Constraints and Functions

If you are planning to make a table constraint that is more complex than a simple check against a field or two then I recommend using functions. By creating a function you can make complex logic by which you can return True Or False states that indicate to a constraint if the data is what you need it to be. You can also add parameters to a function giving you the dynamic possibility to process data being processed.


Lets say that you have function that wants to check if a ID value is a certain numeric ID and then you want to make sure that a row being inserted does not have a NULL value in a certain field.

Here is some sample code:

CREATE FUNCTION [dbo].[CheckForNullByID]


   — Add the parameters for the function here

   @someID int,

   @someFieldNotNULL char(11)





   DECLARE @retValue bit = 0

   IF @someID = 40


          IF @someFieldNotNULL IS NOT NULL


                 SET @retValue = 1



                 SET @retValue = 0



          SET @retValue = 1

   RETURN @retValue



Then you call the function in your constraint like the following expression:


Thats it :)!!!

Hope this helps 🙂

Good to Know: Windows Server 2012 – Part 2

Part 2 of the good to know things of Windows Server 2012:

Backup using GPMC
View Hidden Folders in Active Directory Users And Computers
Software Restriction Policies Rules
How manage Published (a.k.a Metro) Apps in Windows 8 using Group Policy
Understanding Connection Security Rules
How to Enable Authenticated Firewall Bypass
Filter the scope of Group Policy according to security group membership
Block Inheritance – GPO
WMI filtering using GPMC – GPO
User Rights Assignment
Windows Authorization Manager
Backing up, Restoring, Migrating, and Copying GPOs
Group Policy Cmdlets in Windows PowerShell
Port Virtual Local Area Network (PVLAN) and Trunk Mode 
Backing Up and Restoring Virtual Machines 
Backing Up Hyper-V Virtual Machines 
Resource Metering
Hyper-V Resource Metering in Windows server 2012
Windows Deployment Services

Changing Active Directory user passwords in a .NET Web Application

Here are some tips on how to allow your web application to change passwords to Active Directory. There are several ways which all work in a similar but different way. This is one of them and what you need to take into consideration.

Here I will concentrate in the code logic and configurations what you need to take and do.

These are the following steps you need to take:

1. Create a web form for you password reset

2. Create a account with just enough privileges to set or reset user passwords

3. Impersonate this account and reset or set a new password under this password “admin” account

And a small sample code on how to change a password:

using (var context = new PrincipalContext(ContextType.Domain, “domain”, “username”, “password”))


     using (var user = UserPrincipal.FindByIdentity(context, IdentityType.SamAccountName, “username whose password to change”))



//// or

                                    //user.ChangePassword(“oldPassword”, “newpassword”);