Monday, December 21, 2015

Display jquery dialog in parent window

The example below is a simple way to display a dialog in the parent window from an iframe.
  • Include jquery and jqueryui into your parent window
  • After this you can access to the parent JQuery object within iframe
   <script type="text/javascript">
         $(document).on("click", "[id*=btnShowPopup]", function () {
            var $jParent = window.parent.jQuery.noConflict();
            var dlg1 = $jParent('#editGiveawayDialog');
              dlg1.dialog({
               title: "Display Dialog",
               width: 550,
               height: 300,
               zIndex: 10000,
                 buttons: {
                   Ok: function () {
                     dlg1.dialog('close');
                   },
                   Cancel: function () {
                     dlg1.dialog('close');
                   }
                  },
                   modal: true
               });
               return false;
           });
            </script>

Hope this helps! :)

Sunday, November 29, 2015

CS0122: 'System.Configuration.StringUtil' is inaccessible due to its protection level

In Visual Studio

File - Open - Website
GoTo: C:\Windows\Microsoft.NET\Framework\v4.0.30319\ASP.NETWebAdminFiles
Open
Now open App_Code\WebAdminPage.cs
GoTo Line 989
Comment out the current text and paste
string appId = (String.Concat(appPath, appPhysPath).GetHashCode()).ToString("x", CultureInfo.InvariantCulture);


Simple Encryption and Decryption Class C#

For anyone looking for a simple encryption class using Rijndael algorithm, enjoy!
using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;
using System.IO;

public static class EncryptionUtils { public static byte[] GenerateKey() { RijndaelManaged provider = new RijndaelManaged(); provider.GenerateKey(); return provider.Key; } public static byte[] GenerateIV() { RijndaelManaged provider = new RijndaelManaged(); provider.GenerateIV(); return provider.IV; } public static string Decrypt(byte[] encryptedBytes, byte[] key, byte[] iv) { RijndaelManaged provider = new RijndaelManaged(); MemoryStream ms = new MemoryStream(); using (CryptoStream cryptoStream = new CryptoStream(ms, provider.CreateDecryptor(key, iv), CryptoStreamMode.Write)) { cryptoStream.Write(encryptedBytes, 0, encryptedBytes.Length); } return Encoding.UTF8.GetString(ms.ToArray()); } public static byte[] Encrypt(string value, byte[] key, byte[] iv) { RijndaelManaged provider = new RijndaelManaged(); byte[] valueBytes = Encoding.UTF8.GetBytes(value); MemoryStream ms = new MemoryStream(); using (CryptoStream cryptoStream = new CryptoStream(ms, provider.CreateEncryptor(key, iv), CryptoStreamMode.Write)) { cryptoStream.Write(valueBytes, 0, valueBytes.Length); } return ms.ToArray(); }

Saturday, October 10, 2015

Disable Search In Toolbar For Windows 10

If your like me and don't care to have a search bar directly adjacent to the Windows start menu button after installing Windows 10.  The steps below will show you how to remove it.


First, right-click on the up arrow as demonstrated in the snapshot below. Next, hover your mouse pointer over the "Search" (or "Cortana") option, then a submenu will appear.

Choose "Hidden" here to disable the taskbar search altogether, or select "Show icon" to reduce the search bar down to a small icon.Choose "Hidden" here to disable the taskbar search altogether, or select "Show icon" to reduce the search bar down to a small icon.



Congrats!!  You've removed the search bar.

Friday, July 10, 2015

Disable autocomplete in Chrome

Originally when I was given the task to disable autocomplete. I thought it would be no problem, but that was far from reality. I tried adding autocomplete="off" to the input tag but it continued to show in chrome. Although, it did seemed OK in IE and Firefox. After a few hours of frustration. I decided to use "false" as the value instead of "off" which resolved the issue. Below is a snippet of the working code. 


//Use this for IE
autocomplete="off"

//Use this for Chrome
autocomplete="false"


//Form Example
// You can also add it to the form so you won't need to add it individually.
<form id="form1">
<input id="txtName" type="text" autocomplete="false" />
<input id="txtEmail" type="text" autocomplete="false" />
<input id="btnSubmit" type="button" value="Submit" />
</form>