<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Nobdy</title>
	<atom:link href="http://www.nobdy.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nobdy.com</link>
	<description>.NET Developer With a Blog</description>
	<lastBuildDate>Thu, 09 Jun 2011 03:42:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Get Identity Column Name At Runtime in LINQ to SQL</title>
		<link>http://www.nobdy.com/csharp/get-identity-column-name-at-runtime-in-linq-to-sql/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://www.nobdy.com/csharp/get-identity-column-name-at-runtime-in-linq-to-sql/#comments</comments>
		<pubDate>Tue, 07 Jun 2011 06:25:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://www.nobdy.com/?p=54</guid>
		<description><![CDATA[This is a small post but it might be helpful. I have created a Table Called &#8220;Test&#8221; in Database with 2 Columns. 1. CategoryId -> Primary Key, Identity Column, Not Null 2. Name -> nVarchar(100), Not Null Drag and Drop &#8230; <a href="http://www.nobdy.com/csharp/get-identity-column-name-at-runtime-in-linq-to-sql/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This is a small post but it might be helpful.</p>
<p>I have created a Table Called &#8220;Test&#8221; in Database with 2 Columns.<br />
1. CategoryId -> Primary Key, Identity Column, Not Null<br />
2. Name -> nVarchar(100), Not Null</p>
<p>Drag and Drop that table on LinQToSql Context.dbml file.<br />
<a href="http://www.nobdy.com/wp-content/uploads/2011/06/IdentityColumn.jpg#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed"><img src="http://www.nobdy.com/wp-content/uploads/2011/06/IdentityColumn.jpg" alt="" title="IdentityColumn" width="247" height="165" class="aligncenter size-full wp-image-55" /></a></p>
<p>In Code Behind:</p>
<pre name="code" class="csharp">
protected void Page_Load(object sender, EventArgs e)
    {
        using (var context = new Context())
        {
            ltIdentity.Text = context.Mapping.GetMetaType(typeof(Test)).DBGeneratedIdentityMember.Name;
        }
    }
</pre>
<p>ltIdentity is a Literal on the webpage.<br />
<a href="http://www.nobdy.com/wp-content/uploads/2011/06/IdentityColumn.zip#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed">Click here</a> to download the code.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nobdy.com/csharp/get-identity-column-name-at-runtime-in-linq-to-sql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery Update Panel Progress Using jQuery BlockUI Plugin</title>
		<link>http://www.nobdy.com/asp-net/jquery-update-panel-progress-using-jquery-blockui-plugin/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://www.nobdy.com/asp-net/jquery-update-panel-progress-using-jquery-blockui-plugin/#comments</comments>
		<pubDate>Fri, 03 Jun 2011 18:09:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.nobdy.com/?p=48</guid>
		<description><![CDATA[This post explains how you can use jQuery BlockUI Plugin to show Progress during postback made via UpdatePanel. Normally we have to add UpdateProgress to show progress during async postbacks. Using this tutorial, You will no longer require UpdateProgress and &#8230; <a href="http://www.nobdy.com/asp-net/jquery-update-panel-progress-using-jquery-blockui-plugin/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p> This post explains how you can use jQuery BlockUI Plugin to show Progress during postback made via UpdatePanel. Normally we have to add UpdateProgress to show progress during async postbacks. Using this tutorial, You will no longer require UpdateProgress and still you will be able to show great looking progressbar using <a href="http://jquery.malsup.com/block/" target="_blank" rel="nofollow">BlockUI plugin</a>.<br />
<a href="http://www.nobdy.com/wp-content/uploads/2011/06/UpdatePanelProgressBar.jpg#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed"><img src="http://www.nobdy.com/wp-content/uploads/2011/06/UpdatePanelProgressBar.jpg" alt="" title="Update Panel Progress Bar" width="590" height="335" class="aligncenter size-full wp-image-50" /></a><span id="more-48"></span><br />
JavaScript:</p>
<pre name="code" class="javascript">
function showProgress() {
    Sys.WebForms.PageRequestManager.getInstance().add_beginRequest.add_beginRequest(function () {
        $.blockUI({ message: $('#divBlock'), css: { border: 'none', background: 'transparent'} });
    });
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(function () {
        $.unblockUI();
    });
}
</pre>
<p>I have created a function named showProgress. This function uses add_beginRequest and add_endRequest of PageRequestManager.</p>
<p>The <strong>beginRequest</strong> event is raised before the processing of an asynchronous postback starts and the postback is sent to the server. You can use this event to call custom script to set a request header or to start an animation that notifies the user that the postback is being processed.</p>
<p>The <strong>endRequest</strong> event is raised after an asynchronous postback is finished and control has been returned to the browser. </p>
<p>So my above code uses these two events to BlockUI and unblockUI.</p>
<p>I have a div containing loading image in my aspx page. You can use same div and Javascript in Master page and that will enable progress for all update panels in the application.</p>
<pre name="code" class="html">
<div style="display: none" id="divBlock">
        <asp:Image runat="server" ID="Image1" ImageUrl="~/Images/Loading.gif" AlternateText="Loading.." />
    </div>
</pre>
<p>By Default this div is hidden by using css &#8220;display:none&#8221;; We pass the ID of the div to blockUI plugin.</p>
<p>Easy Isn&#8217;t it. You can download the source code by <a href="http://www.nobdy.com/wp-content/uploads/2011/06/UpdatePanelProgress.zip#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed">Clicking Here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nobdy.com/asp-net/jquery-update-panel-progress-using-jquery-blockui-plugin/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ASP.NET Validators Pimped using jQuery</title>
		<link>http://www.nobdy.com/asp-net/asp-net-validators-pimped-using-jquery/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://www.nobdy.com/asp-net/asp-net-validators-pimped-using-jquery/#comments</comments>
		<pubDate>Tue, 31 May 2011 18:25:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.nobdy.com/?p=25</guid>
		<description><![CDATA[I was looking for a solution which will improve how Error Message is displayed while using Validators like RequiredFieldValidator. I love jQuery and I was looking for something to Pimp my validators using jQuery. I found few solutions but I &#8230; <a href="http://www.nobdy.com/asp-net/asp-net-validators-pimped-using-jquery/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I was looking for a solution which will improve how Error Message is displayed while using Validators like RequiredFieldValidator. I love jQuery and I was looking for something to Pimp my validators using jQuery. I found few solutions but I was not satisfied with that. So I planned to code it myself.</p>
<p>here is the Screenshot of how Validators will look like:</p>
<p><a href="http://www.nobdy.com/wp-content/uploads/2011/05/jquery-validator.jpg#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed"><img class="alignnone size-full wp-image-33" title="jquery validator" src="http://www.nobdy.com/wp-content/uploads/2011/05/jquery-validator.jpg" alt="" width="519" height="375" /></a></p>
<p>As you can see from the screenshot, The validators looks better than what is provided by Microsoft.<br />
<span id="more-25"></span><br />
The main part of the code is JavaScript code which can be used in any existing application.</p>
<p>Here is the Code:</p>
<pre name="code" class="javascript">$(document).ready(function () {
    $('.causeValidation').click(function () {
        $('.error-message').remove();
        var grp = $(this).parent().attr("class");
        $.each(Page_Validators, function () {
            if (this.validationGroup == grp || grp == "") {
                this.style.display = 'none';
                var $control = $('#' + this.controltovalidate);
                if (!this.isvalid) {
                    $control.parent().addClass('validation-error');
                    $control.parent().append('<span class="error-message">' + this.errormessage + '</span>');
                    $control.focus(function () {
                        $('.error-message', $(this).parent()).remove();
                        $(this).parent().removeClass('validation-error');
                    });
                }
            }
        });
    });
});</pre>
<p>The above code disables error messages from regular Validators and replace them with custom one.</p>
<p>This validator also support ValidationGroup. If you have more than one forms on same page and you want to validate each of them separately, you need to do a simple tweak. I will explain that later on.</p>
<p>For now for the code to work, You have to assign CssClass &#8220;causeValidation&#8221; to Button.</p>
<p>Here is the aspx code for this example:</p>
<pre name="code" class="html">
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<link href="Style/form.css" rel="stylesheet" type="text/css" />
    <script src="Scripts/jquery-1.3.2.min.js" type="text/javascript"></script>
    <script src="Scripts/validator.js" type="text/javascript"></script>
    <title></title>
</head>
<body>
<form id="form1" runat="server">
<div class="form">
<div class="columns">
<div>
                <label>
                    User Name</label>
                <asp:TextBox runat="server" ID="txtUserName"></asp:TextBox>
                <asp:RequiredFieldValidator runat="server" ID="reqUserName" ControlToValidate="txtUserName" ErrorMessage="user Name is required."
                    Display="None">
                </asp:RequiredFieldValidator>
            </div>
<div>
                <label>
                    Password</label>
                <asp:TextBox runat="server" ID="txtPassword" TextMode="Password"></asp:TextBox>
                <asp:RequiredFieldValidator runat="server" ID="reqPassword" ControlToValidate="txtPassword" ErrorMessage="Password is required."
                    Display="None">
                </asp:RequiredFieldValidator>
            </div>
<div>
                <label>
                    First Name</label>
                <asp:TextBox runat="server" ID="txtName"></asp:TextBox>
                <asp:RequiredFieldValidator runat="server" ID="reqName" ControlToValidate="txtName" ErrorMessage="First Name is required."
                    Display="None">
                </asp:RequiredFieldValidator>
            </div>
<div>
                <label>
                    Last Name</label>
                <asp:TextBox runat="server" ID="txtLastName"></asp:TextBox>
                <asp:RequiredFieldValidator runat="server" ID="reqLastName" ControlToValidate="txtLastName" ErrorMessage="Last Name is required."
                    Display="None">
                </asp:RequiredFieldValidator>
            </div>
<div>
                <label>
                    City</label>
                <asp:TextBox runat="server" ID="txtCity"></asp:TextBox>
                <asp:RequiredFieldValidator runat="server" ID="reqCity" ControlToValidate="txtCity" ErrorMessage="City is required."
                    Display="None">
                </asp:RequiredFieldValidator>
            </div>
<div style="text-align: center;">
                <span>
                    <asp:Button runat="server" ID="btnTest" Text="Test Validator" CssClass="causeValidation" />
                </span>
            </div>
</div>
</div>
</form>

</body>
</html>
</pre>
<p>As you can see btnTest is assigned a CssClass &#8220;causeValidation&#8221;.<br />
You can also set Display property of the Validators to None;</p>
<p>The appearance of the form is controlled by CSS. You can modify it according to your needs.</p>
<p>Here is the CSS code used for this example:</p>
<pre class="css" name="code">
body{font-family:Calibri; font-size:14px; color:#888; background-color:#fefefe;}

.form{width:500px; margin:auto; border:6px solid #CCE7F4;}
.form .columns div{padding:5px; background-color:#EEF7FB; border-bottom:1px solid #CCE7F4; margin-bottom:1px;}
.form label{display:inline-block; width:150px; font-weight:bold; font-size:15px;}
.form input[type="text"], .form input[type="password"]{font-size:15px; padding:5px; width:300px; border:2px solid #CCE7F4;}
.form .validation-error *{color:Red;}
.form .validation-error label{color:Red;}
.form .validation-error input{border: 1px solid #CC0000; background: #FCF0EF url(images/error-bg.png) repeat-x top; color: #CC0000; margin-right: 5px;}
.form .error-message{display:block; font-style:italic; background:url(images/icon_error.png) no-repeat;margin:5px; padding-left:20px; margin-left:150px;}</pre>
<p><strong>Implementing for ValidationGroup</strong></p>
<p>lets say you have ValidationGroup named &#8220;grpInsert&#8221; for a form. You have to assign Class of same name as ValidationGroup to the parent element of the button.</p>
<p>Example:</p>
<pre name="code" class="html">
<span class="grpInsert">
Button Goes Here
</span>
</pre>
<p>Important:</p>
<p>You should always enclose Button to container element with no class if you are not using any ValidationGroup. in my example,I have used <span> </span></p>
<p><a title="Source Code" href="http://www.nobdy.com/wp-content/uploads/2011/05/Jquery-Validators.zip#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed">Here is the Source code for above example.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.nobdy.com/asp-net/asp-net-validators-pimped-using-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>High Quality Thumbnail Generator At Runtime Using ASP.NET And C#</title>
		<link>http://www.nobdy.com/asp-net/high-quality-thumbnail-generator-at-runtime-using-asp-net-and-c/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://www.nobdy.com/asp-net/high-quality-thumbnail-generator-at-runtime-using-asp-net-and-c/#comments</comments>
		<pubDate>Mon, 30 May 2011 18:09:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://www.nobdy.com/?p=7</guid>
		<description><![CDATA[Welcome to my first post. I have coded a class to generate High quality thumbnails at runtime and also cache these images. This class &#8220;Images.cs&#8221; is inherited by IHttpHandler so that this can be used as Handler to serve thumbnails. &#8230; <a href="http://www.nobdy.com/asp-net/high-quality-thumbnail-generator-at-runtime-using-asp-net-and-c/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Welcome to my first post.<br />
I have coded a class to generate High quality thumbnails at runtime and also cache these images.</p>
<p>This class &#8220;Images.cs&#8221; is inherited by IHttpHandler so that this can be used as Handler to serve thumbnails. Thumbnail Width and Height is passed to handler using QueryString parameters.</p>
<pre name="code" class="c-sharp">
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Web;
using System.IO;

namespace Xpertz.Base.Handler
{
    public class Images : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {

            var file = context.Request.FilePath.Replace(".ashx", String.Empty);
            var fileName = file.Substring(file.LastIndexOf('/') + 1);
            var extension = file.Substring(file.LastIndexOf('.'));

            int width;
            int height;
            int.TryParse(context.Request["w"], out width);
            int.TryParse(context.Request["h"], out height);

            var path = context.Server.MapPath(file);
            if (!File.Exists(path))
            {
                context.Response.StatusCode = 404;
                context.Response.End();
                return;
            }
            context.Response.Clear();
            context.Response.Cache.SetExpires(DateTime.Now.AddDays(10));
            context.Response.Cache.SetCacheability(HttpCacheability.Public);
            context.Response.Cache.SetValidUntilExpires(false);
            context.Response.AddHeader("content-disposition", "inline;filename=" + fileName);

            using (var fs = new FileStream(path,
                FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
            {
                using (var img = new Bitmap(fs))
                {
                    using (var ms = new MemoryStream())
                    {
                        Bitmap bmpOut = null;

                        if (width > 0 &#038;&#038; height == 0)
                        {
                            double tmp = img.Height / (double)img.Width;
                            bmpOut = GenerateThumb(img, width, (int)(width * tmp));
                        }
                        if (height > 0 &#038;&#038; width == 0)
                        {
                            double tmp = img.Width / (double)img.Height;
                            bmpOut = GenerateThumb(img, (int)(height * tmp), height);
                        }
                        if (height > 0 &#038;&#038; width > 0)
                        {
                            bmpOut = GenerateThumb(img, width, height);
                        }
                        if (height == 0 &#038;&#038; width == 0)
                        {
                            bmpOut = GenerateThumb(img, img.Width, img.Height);
                        }
                        if (GetContentType(extension) == "image/jpeg")
                        {
                            var info = ImageCodecInfo.GetImageEncoders();
                            var encoderParameters = new EncoderParameters(1);
                            encoderParameters.Param[0] = new EncoderParameter(Encoder.Quality, 100L);
                            if (bmpOut != null) bmpOut.Save(ms, info[1], encoderParameters);
                        }
                        else if (bmpOut != null) bmpOut.Save(ms, GetImageFormat(extension));
                        var arrImg = new byte[ms.Length];
                        ms.Position = 0;
                        ms.Read(arrImg, 0, (int)ms.Length);
                        img.Dispose();
                        context.Response.ContentType = GetContentType(extension);

                        context.Response.BinaryWrite(arrImg);
                        context.Response.End();
                    }
                }
            }

        }

        private static Bitmap GenerateThumb(Bitmap bmp, int width, int height)
        {
            Bitmap result = null;

            try
            {
                var sourceWidth = bmp.Width;
                var sourceHeight = bmp.Height;
                if (width > sourceWidth) width = sourceWidth;
                if (height > sourceHeight) height = sourceHeight;
                var widthPercent = (width / (float)sourceWidth);
                var heightPercent = (height / (float)sourceHeight);
                var finalPercent = heightPercent < widthPercent ? widthPercent : heightPercent;
                var destWidth = (int)(sourceWidth * finalPercent);
                var destHeight = (int)(sourceHeight * finalPercent);
                result = new Bitmap(width, height, PixelFormat.Format24bppRgb);
                result.SetResolution(bmp.HorizontalResolution, bmp.VerticalResolution);
                var graphics = Graphics.FromImage(result);
                graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
                graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
                graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
                graphics.FillRectangle(Brushes.White, 0, 0, width, height);
                graphics.DrawImage(bmp, new Rectangle(0, 0, destWidth, destHeight),
                    new Rectangle(0, 0, sourceWidth, sourceHeight), GraphicsUnit.Pixel);
                bmp.Dispose();
                graphics.Dispose();
            }
            catch
            { }
            return result;
        }

        private static ImageFormat GetImageFormat(string ext)
        {
            switch (ext.ToLower())
            {
                case ".gif": return ImageFormat.Gif;
                case ".jpg":
                case ".jpeg": return ImageFormat.Jpeg;
                case ".png": return ImageFormat.Png;
                case ".bmp": return ImageFormat.Bmp;
                default: throw new NotSupportedException("Invalid Image Format");
            }
        }
        private static string GetContentType(string ext)
        {
            switch (ext.ToLower())
            {
                case ".gif": return "image/gif";
                case ".jpg":
                case ".jpeg": return "image/jpeg";
                case ".png": return "image/png";
                case ".bmp": return "image/bmp";
                default: throw new NotSupportedException("Invalid Image Format");
            }
        }
        public bool IsReusable
        {
            get
            {
                return true;
            }
        }
    }
}
</pre>
<h2>Usage</h2>
<p>To use this Handler, make following changes in web.config file.</p>
<pre name="code" class="xml">
<httpHandlers>
      <add verb="*" path="*.jpg.ashx" type="Xpertz.Base.Handler.Images" ></add>
      <add verb="*" path="*.jpeg.ashx" type="Xpertz.Base.Handler.Images" ></add>
      <add verb="*" path="*.png.ashx" type="Xpertz.Base.Handler.Images" ></add>
      <add verb="*" path="*.gif.ashx" type="Xpertz.Base.Handler.Images" ></add>
      <add verb="*" path="*.bmp.ashx" type="Xpertz.Base.Handler.Images" ></add>
    </httpHandlers>
</pre>
<p>Now you are all set to use this Handler. Call this handler be appending ".ashx" in the Image URL<br />
example:<br />
http://www.example.com/images/test.jpg<strong>.ashx?w=125&#038;h=125 </strong><br />
in the above URL,<br />
<strong>w</strong> = Width of thumbnail (Optional Parameter)<br />
<strong>h</strong> = Height of thumbnail (Optional Parameter)</p>
<p><a href="http://www.nobdy.com/wp-content/uploads/2011/05/Thumbnail.zip#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed">Click Here to download the Sample Code</a>. Don't forget to leave your comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nobdy.com/asp-net/high-quality-thumbnail-generator-at-runtime-using-asp-net-and-c/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

