ASP.NET WebForms Notification Control

Posted on Thu 19 June 2014 in ASP.NET • Tagged with aspnetLeave a comment

In 2012 I wrote about using notification in ASP.NET WebForms and most of questions I’ve got are asking about why it isn’t working, so I thought I can make it easier for developers by creating ASP.NET Server Control that has notification functionality and developers can reuse it like any ASP.NET Server Control in their toolbox.

About the Project

Notification Control is open source/free ASP.NET server control like ASP.NET Ajax toolkit controls, it’s wrapper for awesome jQuery plug-in called jNotify to use it’s functionality from code behind, it’s on GitHub, please fork it, or test it and report bugs/issues on GitHub.

You can find demo here

How to Install

Download via GitHub repository

  1. Download the repository as  Zip file.

  2. Run Visual Studio, and open project.Screenshot-0016

  3. Build the project.Screenshot-0026Screenshot-0019

  4. Go to bin/Release folder and locate the CustomControls.NotificationControl.dll file. Screenshot-0020

Download via Nuget:

  1. In Visual Studio open Package Manager Console and type Install-Package NotificationControl, wait until the package download is done, and open the project folder, then browse to {ProjectFolder}/NotificationControl.{version} you’ll find the DLL file.

  2. In your ASP.NET WebForms project open any .ASPX file then …

Continue reading

Add Image Zoom to ASP.NET WebForm GridView

Posted on Mon 27 May 2013 in ASP.NET • Tagged with aspnet, gridviewLeave a comment

The main reason I’m writing this article is to let you know there is always some way better and simpler to don something, one day I want to add image zoom feature to ASP.NET WebForms GridView that shows list of products with thumbnail, and instead of user click on row to get the product information and see a full picture of the product, I want user to just when hovering on the image a big preview of it appears, I found this jQuery plug-in called elevateZoom I love it because it’s simple, have a lot of feature, and easy to configure.

Now the change is how to add this plug-in to every single image in every row in GridView, I googled but unfortunately I found many of complex solution and I thought these developers intend to make this complex, but no this isn’t that complex, I denied all of them even they are working and I’ll tell you what If done in the end of this article, so let us how to get this done.

First download the plug-in, reference jQuery to your ASP.NET application, second add the GridView control to your form and …

Continue reading

Storing password in plain text, you’re doing it wrong

Posted on Wed 06 March 2013 in ASP.NET • Tagged with security, dotNet, CsharpLeave a comment

Hacking for password

If you’re software developer then there is big chance you’ll implement user login feature, and you must store the username and password in your system. Most of developers stored these precious information in database as plain text, yes we did include myself I was doing it wrong, and if you’re doing it please stop and read this article to know how to do it right and being awesome.

Username, Password, or Pin codes these are precious information, and if hacker or even internal employee stole the database he can do whatever he wants with your users information. So How to keep these information safe? The answer is hashing it.

Why I was not doing that? I was lazy and every time I googled/binged/searched about this, I found many complex How-To articles, but last week I finally found something simple and it’s the reason I’m writing this article.

What is hashing?

Hashing is encoding string "message” to hash value and you can’t reproduce the original string “message” from hash value, so it’s one way cryptographic algorithm, it’s different than encryption that it’s  two way cryptographic algorithm.

How to Hash password …

Continue reading

Add elegant style to ASP.NET WebForms GridView control

Posted on Wed 11 July 2012 in ASP.NET • Tagged with aspnet, gridviewLeave a comment

5628591299_8d5839c072

We are developers whom use the left side of our brains that why we suck in designing; we’ll use the already exist styles while developing ASP.NET web application, that what we’ll do if we don’t have a designer in our team, but thanks for the CSS framework over the internet which make our like more easier.

Nowadays I’m playing with Twitter Bootstrap CSS framework and I find myself create very neat and awesome looking ASP.NET applications by just using the already defined CSS classes in the framework, it’s so easy and the documentation is easy to understand and readable, you can find the documentation right here.

So let’s get into the business, the most commonly used ASP.NET Control GridView is very ugly if you don’t apply a style to it, it’ll look like an awful HTML table with bunch of rows and columns, sure you can use the ready made styles “Auto Format” created by Microsoft team, but also you can apply much better style to it, let’s find how.SNAG-0089

I’ll show you how to apply 2 styles to GridView:

  1. Twitter Bootstrap.
  2. ASP.NET Dynamic Data.

Twitter …

Continue reading

ASP.NET Expressions

Posted on Thu 10 May 2012 in ASP.NET • Tagged with aspnet, webformsLeave a comment

ASP.NET Expression is written inline surrounded with <% %> in other words you will write them with your markup in .ASPX files for specific task, for example if want to access a connection string there an expression for that

<%$ ConnectionStrings:DefaultConnection %>

Let’s lists all ASP.NET Expression and it’s task:

  1. Directive Expression <%@ .. %> 

    • It’s used in Web Forms .ASPX files or User Control .ASCX files to set settings, for example the Page directive where you can declare Title, Master Page, Language, etc. aspx <%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="ASPNETExpressions._Default" %>
  2. Data-Binding Expression <%# .. %>

    • Create binding between server control with data source when calling DataBind() method, most of the time you’ll see this expression inside Data Bound Controls like GridView and DetailView.

      aspx <asp:TextBox runat="server" ID="txtFirstName" Text="<%# Eval("FirstName") %>"/>

  3. Expression Builder <%\$ .. %>

    • This expression is used to set controls properties that located in configuration files Web.Config such as AppSettings, ConnectionStrings, or Resources
    • Its syntax is <$ Expression Prefix: Expression Value %> aspx <%$ ConnectionStrings:DefaultConnection %>
  4. Server-side Comment Expression <%-- .. --%>

    • It’s to comment a block of code so that it’ll not rendered or executed inside the page. aspx <%— This …
Continue reading

ASP.NET Page Lifecycle in Plain English

Posted on Thu 03 May 2012 in ASP.NET • Tagged with aspnetLeave a comment

asp.net

ASP.NET Page Lifecycle is very important piece of knowledge every ASP.NET developer must know, and unfortunately some of ASP.NET developer out there don’t know and they think it’s not important to know.

Let’s dig in and let’s examine ASP.NET Lifecycle but in short list and description:

  1. PreInit():

    • In this event all Controls created and Initialized with their default values. You can create dynamic Controls here. You can set theme programmatically here
  2. OnInit():

    • In this event you can read the Controls properties the were set in Design Mode and can not read values changed by user.
  3. LoadViewState():

    • This event fires only if the page is posted back IsPostback == true and here View State data where are stored in hidden form fields get de-serialized and loads all controls View State data.
  4. LoadPostBackData():

    • This event only fires when Page is posted back and Controls which implement IPostBackDataHandler interface get loaded with values from HTTP POST data.
  5. Page_Load():

    • This event is well known among ASP.NET developers and here Page gets loaded and after it all Load() events of Page Controls fired.
  6. Control Event Handlers:

    • These are basically event handlers like Button click event handler Button_Click …
Continue reading

Using Notification in ASP.NET WebForms

Posted on Thu 02 February 2012 in ASP.NET • Tagged with aspnet, jnotify, jqueryLeave a comment

I always asked myself, how can I show a neat notification and call it from Page code behind? I want to call this notification after doing something in code behind, for example notify user that “Record Inserted Successfully” and this notification looks like the one on Twitter and Stackoverflow. I found jQuery plug-in called jNotify has what I want from the notification, and ASP.NET has the Method “ClientScriptManager.RegisterStartupScript Method” to add Script to page on runtime, so why not combine 2 together and create a helper method  plus make it extension method for Page.

Helper Method:

This is the most important part, here where the 2 part I mentioned above.

using System.Web.UI;

namespace jQueryNotification.Helper
{
    public static class NotificationHelper
    {
        /// <summary>
        /// Shows the successful notification.
        /// </summary>
        /// <param name="page">The page.</param>
        /// <param name="message">The message.</param>
        public static void ShowSuccessfulNotification(this Page page, string message)
        {
            page.ClientScript.RegisterStartupScript(page.GetType(), "notificationScript",
                                                    "<script type='text/javascript'>  $(document).ready(function () { $.jnotify('" +
                                                    message + "'); });</script>");
        }
    }
}

jNotify Script and Style:

In order to use the helper method you need to add jQuery script and jNotify script and style

<link href="Styles/jquery.jnotify.css" rel="stylesheet" type="text/css" />
<script …
Continue reading

Add AJAX effect to ASP.NET Webforms postbacks

Posted on Sun 01 January 2012 in ASP.NET • Tagged with ajax, asp.net, aspnet, postback, tips, tricksLeave a comment

If you want to add AJAX effect to ASP.NET webforms  full postbacks, add this meta tags to your page, or even better add it the your master page.

<meta content="blendTrans(Duration=0.2)" http-equiv="Page-Enter" /></meta>
<meta content="blendTrans(Duration=0.2)" http-equiv="Page-Exit" /></meta>

This effect will remove the blinking  effect from ASP.NET pages, and they call it fajax aka the fake alternative to AJAX

Continue reading

Enforce Join option in Crystal Reports

Posted on Wed 08 June 2011 in ASP.NETLeave a comment

Link option

SAP Crystal Reports enables you to enforce the use of tables while you're specifying joins:

Not Enforced

When you select this option, the link you've created is used only if it's explicitly required by the Select statement. This is the default option. Your users can create reports based on the selected tables without restriction (that is, without enforcement based on other tables).

Enforced From

When you select this option, if the "to" table for the link is used, the link is enforced. For example, if you create a link from Table A to Table B using Enforce From and select only a field from Table B, the Select statement will still include the join to Table A because it is enforced. Conversely, selecting only from Table A with the same join condition will not cause the join to Table B to be enforced.

Example: Employee.Store_id –> Store.id, CP will enforce the join if the report has at least one of Store’s fields.

Enforced To

When you select this option, if the "from" table for the link is used, the link is enforced. For example, if you create a link from Table A to Table B using Enforce To …

Continue reading

Enable ASP.NET 32-bit application on 64-bit environment

Posted on Fri 11 March 2011 in ASP.NETLeave a comment

If you’re deploying 32-bit ASP.NET application on 64-bit environment, you can enable 32-bit in IIS, you have 2 ways to do it by:

  1. Set Application Pool Defaults.
  2. Change specific Application Pool Advanced Settings.

IIS Manager

Here is the setting you need to change either in number 1 or 2:

Application Pool settings

Continue reading