Thursday, November 19, 2009

check out the PDC 09 videos

check out the PDC 09 videos here

Managed Extensibility Framework

The Managed Extensibility Framework (MEF) has been getting a lot of interest lately and it’s something that’s out on CodePlex and it’s also part of .NET Framework 4.0.

It’s also part of Silverlight 4.

The name’s a good one – it’s a framework for building an application that is made up of a bunch of loosely coupled components with a lot of flexibility around component discovery, registration, lookup and lifetime management. If I had to sum it up in my own words I’d say something like;

MEF composes an application by extensibly discovering a set of components which offer exported functionality and ( possibly ) rely on imported functionality. The link between the two is a simple string name ( a MEF “contract name” ) which is usually represented by a .NET type name and MEF has the capability to plug things together where it finds ( possibly further constrained ) matches.

Read full post of mike here

How to check if Silverlight Running out of browser or in the browser ?

As Silverlight increases its Out of Browser features it will become more important to detect if the application is running in or out of the browser.  This is the check:

if (Application.Current.IsRunningOutOfBrowser)
{
// Out of Browser

}
else

{
// in the browser

}

Silverlight 4 Beta is Now Available

Yesterday, at the PDC in Los Angeles, Scott Guthrie announced the availability of Silverlight 4 beta, just four months after bringing Silverlight 3 to market. With the help of several customers we showcased the new features that will enable developers to create the highest quality media and RIA applications for the Web and desktop. These powerful new features offer developers significant benefits in rapidly creating rich software experiences, and include:

· Enhancements to Silverlight out-of-browser capabilities which enable high quality application experiences on the desktop;

· Advancements in business application development, including access to other Microsoft products like SharePoint 2010, Office, and Internet Information Services (IIS);

· The most amazing HD-quality video experiences on the Web with native multicast and offline DRM support.

In addition, our list of customers and HD streaming events continues to grow, with 45 percent of Internet-connected devices worldwide using Silverlight. Today we highlighted the diverse ways Silverlight is being used to power the applications we use every day such as, Portland, OR startup SnapFlow, who demonstrated their new workflow-making platform. We’re also looking forward to helping NBC broadcast the 2010 Vancouver Winter Games in HD-quality video with Silverlight and IIS Smooth Streaming on NBCOlympics.com beginning February 12, 2010.

Drop by the PDC Virtual Pressroom to view Scott Guthrie’s keynote and to find out more information about Silverlight 4 beta. To download Silverlight 4 beta visit the Silverlight.net community site.

Monday, November 9, 2009

NOW, here is a true INDIAN! I was moved to read this young man’s story.

Have you ever seen Mahatma Gandhi??

If not, come and visit Thennur village near Trichy. You cannot see Mahatma Gandhi there. But you can see a ‘Young’ Gandhi there. I got a chance to go there when we went to our friend Thilaga’s marriage. Here is a man who was earning Rs 2 lakhs per month 5years ago in the US. One of his ambitions, from the time he was studying in school, is to serve his village. Hence, after earning some money for his parents, he resigned his job in the US and came to his village to start an NGO in order to support the village. He is just 36 years old now which means he resigned his job when he was 31! He is also called as ‘Ilam Gandhi’ (Young Gandhi).

So, what did he do after resigning his job?? He invested Rs 40 lakhs in Thennur to build a community health center and an informal learning center. Out of the Rs 40 lakhs which he spent, Rs 31 lakhs came out of his own pocket. He started an NGO called ‘Payir’ to help this village

Have a look at his PAYIR’s building’s below:

clip_image001

The community health center:

clip_image002

clip_image003

Informal learning center

clip_image004

Now, he has appointed 5 people who are locals and who function as his staff. They teach proper English to the schools available in their locality.

Local staffs working in Payir

clip_image005

And that is not all! He has created a small IT company within that village. This company has 4 employees as of now, who are all graduates from this village. They have a US client and are currently working on a $2500 project. This IT company is in the middle of a Coconut farm.

Have a look at their IT company below:

The IT company in the middle of a farm

clip_image006

Inside the company

clip_image007

Fan inside the IT company

clip_image008

While working in the US, he used to deposit a little money for his parents as one of his mother’s wishes was to build a house for themselves. With his savings, his parents now live in a big house at Srirangam. See the picture below:

clip_image009

But, that’s not the case with him. He lives in a small hut in that village itself.

Have a look at his room below:

clip_image010

I asked him, how he is able to live without any earnings? His reply was as follows:

“Payir trust provides me with daily food. My trustees have agreed on this. I have built a hut for myself using my past earnings. So shelter is not a problem. I have 3sets of shirts and Vesti(Dhoti) which I can use for the next 2 years. My friends will get me a few dresses once or twice in a year. What more do I need in my life??”.

Have a look at the slipper of the great man who was earning 2Lakhs a month in US:

clip_image011

When I asked, how he will manage in his old age, if he gets any disease, he coolly replied that he will go to a Govt. hospital where everything is free of cost.

My question is: How many of us will dare to act like Senthil ? Many of us have so many dreams in life like becoming a music director, to become a cricketer, to do MBA, go to the Himalayas, help the schools where we studied, to become a district collector etc etc.. But we all lose our dreams just to earn money and want to reach a position which we call it as ‘Status’. We determine our path by seeing what others are doing. We select our needs based on what others have. We select a course to study based on the job availability and its salary rather than our interest for the subject.

Every one forgets that we have only one life to achieve our dream. Many of us chase what we do not want actually. If you still have some of your dreams unfulfilled, remember that you are the reason behind it. Start now and chase your dreams!

Senthil had a dream and he started executing it now! Believe me or not. Senthil started dreaming about Payir organization during his 11th std!

Senthil - The real hero!

clip_image012

Coming to the social aspect of Senthil, how many of us will leave all that we have earned and work for the benefit of others? Have we ever dreamt of doing what Senthil has done?

While returning from Thennur, only one thing was running on my mind. If everyone of us did atleast 0.1% of what Senthil has done, our India will be much better than any other country in this world!!

If many of us continue to focus on personal growth without worrying about our nation, in future, there will be many more Senthil’s around us who would have sacrificed their personal life for the welfare of this country.

Thennur is not just another village in our India map. It is a start of a new beginning for India. Thennur is a proof of the change that youth can bring in our country.

Monday, October 12, 2009

How To Export Data in a DataGrid on an ASP . NET WebForm to Microsoft Excel

  • Start Visual Studio .NET. On the File menu, point to New, and then click Project.
  • In the Project Types pane, click Visual Basic Projects. Under Templates, click ASP.NET Web Application. Name the application ExcelExport and then click OK.
    WebForm1 appears in Design view for you.
  • In Solution Explorer, right-click WebForm1.aspx and then click Rename. Change the name of the file to Bottom.aspx.
  • On the View menu, click HTML Source to add the following DataGrid between the < form > and < / form > tags:

    <asp:datagrid id="DataGrid1" runat="server" GridLines="Vertical" CellPadding="3" BackColor="White" BorderColor="#999999" BorderWidth="1px" BorderStyle="None" Width="100%" Height="100%" Font-Size="X-Small" Font-Names="Verdana"> <SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#008A8C"></SelectedItemStyle> <AlternatingItemStyle BackColor="Gainsboro"></AlternatingItemStyle> <ItemStyle BorderWidth="2px" ForeColor="Black" BorderStyle="Solid" BorderColor="Black" BackColor="#EEEEEE"></ItemStyle> <HeaderStyle Font-Bold="True" HorizontalAlign="Center" BorderWidth="2px" ForeColor="White" BorderStyle="Solid" BorderColor="Black" BackColor="#000084"></HeaderStyle> <FooterStyle ForeColor="Black" BackColor="#CCCCCC"></FooterStyle> <PagerStyle HorizontalAlign="Center" ForeColor="Black" BackColor="#999999" Mode="NumericPages"></PagerStyle> </asp:datagrid>

  • On the View menu, click Design to return to design view.
    The DataGrid appears on the WebForm.
  • On the View menu, click Code to display the code behind the Web Form. Add the following code to the Page_Load event handler:

    Note You must change User ID <username> and password=<strong password> to the correct values before you run this code. Make sure that the user account has the correct permissions to perform this operation on the database.


    ' Create a connection and open it. Dim objConn As New System.Data.SqlClient.SqlConnection("User ID=<username>;Password=<strong password>;Initial Catalog=Northwind;Data Source=SQLServer;") objConn.Open() Dim strSQL As String Dim objDataset As New DataSet() Dim objAdapter As New System.Data.SqlClient.SqlDataAdapter() ' Get all the customers from the USA. strSQL = "Select * from customers where country='USA'" objAdapter.SelectCommand = New System.Data.SqlClient.SqlCommand(strSQL, objConn) ' Fill the dataset. objAdapter.Fill(objDataset) ' Create a new view. Dim oView As New DataView(objDataset.Tables(0)) ' Set up the data grid and bind the data. DataGrid1.DataSource = oView DataGrid1.DataBind() ' Verify if the page is to be displayed in Excel. If Request.QueryString("bExcel") = "1" Then ' Set the content type to Excel. Response.ContentType = "application/vnd.ms-excel" ' Remove the charset from the Content-Type header. Response.Charset = "" ' Turn off the view state. Me.EnableViewState = False
    Dim tw As New System.IO.StringWriter() Dim hw As New System.Web.UI.HtmlTextWriter(tw) ' Get the HTML for the control. DataGrid1.RenderControl(hw) ' Write the HTML back to the browser. Response.Write(tw.ToString()) ' End the response. Response.End()
    End If




  • NOTE: Replace SQLServer in the code with the name of your SQL Server. If you do not have access to a SQL Server that contains the Northwind sample database, modify the connection string to use the Microsoft Access 2002 sample Northwind database:

    provider=microsoft.jet.oledb.4.0; data source=C:\Program Files\Microsoft Office\Office10\Samples\Northwind.mdb

    If you select this method, modify the aforementioned code to use the OleDbClient namespace rather than the SqlClient namespace.

  • On the Project menu, click Add HTML Page. Name the page Top.htm and then click Open.
    Top.htm appears in Design view.
  • On the View menu, click HTML Source. Replace the contents of the HTML source window with the following code:

    <html> <script language="vbscript"> Sub Button1_onclick Select Case Select1.selectedIndex Case 0 ' Use Automation. Dim sHTML sHTML = window.parent.frames("bottom").document.forms(0).children("DataGrid1").outerhtml Dim oXL, oBook Set oXL = CreateObject("Excel.Application") Set oBook = oXL.Workbooks.Add oBook.HTMLProject.HTMLProjectItems("Sheet1").Text = sHTML oBook.HTMLProject.RefreshDocument oXL.Visible = true oXL.UserControl = true Case 1 ' Use MIME Type (In a New Window). window.open("bottom.aspx?bExcel=1") Case 2 ' Use MIME Type (In the Frame). window.parent.frames("bottom").navigate "bottom.aspx?bExcel=1" End Select End Sub </script> <body> Export to Excel Using: <SELECT id="Select1" size="1" name="Select1"> <OPTION value="0" selected>Automation</OPTION> <OPTION value="1">MIME Type (In a New Window)</OPTION> <OPTION value="2">MIME Type (In the Frame)</OPTION> </SELECT> <INPUT id="Button1" type="button" value="Go!" name="Button1"> </body> </html>

  • On the Project menu, click Add HTML Page. Name the page Frameset.htm and then click Open.
    Frameset.htm opens in Design view.
  • On the View menu, click HTML Source. Replace the contents of the HTML source window with the following code:

    <html> <frameset rows="10%,90%"> <frame noresize="0" scrolling="no" name="top" src="top.htm"> <frame noresize="0" scrolling="yes" name="bottom" src="bottom.aspx"> </frameset> </html>

  • In Solution Explorer, right-click Frameset.htm and then click Set As Start Page.
  • On the Build menu, click Build Solution.
  • On the Debug menu, click Start Without Debugging to run the application.
    After the frameset opens in the Web browser, the DataGrid in the bottom frame displays the data from the Northwind database.
  • In the drop-down list, click Automation, and then click Go.
    The DataGrid contents are displayed outside the browser in the Microsoft Excel application window.
  • In the drop-down list, click MIME Type (In a New Window), and then click Go.
    The DataGrid contents are displayed in Excel hosted in a new Web browser window.
    NOTE: If you receive a prompt to open or save the Excel file, click Open.
  • In the drop-down list, click MIME Type (In the Frame) and then click Go.
    The DataGrid contents are displayed in the bottom frame of the frameset in Excel hosted in the Web browser.
    NOTE: If you receive a prompt to open or save the Excel file, click Open.

    enjoy……………………..

  • Friday, October 9, 2009

    How to get the Column information for a Table using T-SQL

    in this sample I am getting the column information for a table called ‘Account’:

    SELECT     Columns.name AS ColumnName, ColumnTypes.name AS Type, Columns.prec AS Precision, Columns.scale AS Scale, 
    Columns.isnullable AS IsNullable
    FROM sys.sysobjects AS Tables INNER JOIN
    sys.syscolumns AS Columns ON Columns.id = Tables.id INNER JOIN
    sys.systypes AS ColumnTypes ON Columns.xtype = ColumnTypes.xtype
    WHERE (Tables.type = 'U') AND (Tables.name = N'Account')
    ORDER BY ColumnName

    Why do ASP.NET control events fire more than once?

    I’ve always wondered about this and here is the answer:

    ASP.NET controls recreates their hierarchy (at a minimum) twice during a single request to the server:

    1. First when the control is being restored to a it's previous state.
    2. Second when all the required modifications are applied.

    Friday, September 18, 2009

    want to know pages that Google crawled just a few minutes back???

     

    In case you have tried the Show Options link that is displayed on top of Google search result, it gives options timeline of which you want search results, like past year, past week, past 24 hrs and recent results. Now like many if you too are interested in finding results that Google spider crawled just a few min back, below is how you do it. the no. in last is taken as past-minutes.

    http://www.google.com/search?q=your_search_query_goes_here&tbs=qdr:n10

    Thursday, September 17, 2009

    ATTITUDE

    If
    A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

    is equal to
    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
    Then,
    Hard Work
    H+A+R+D+W+O+R+K
    8+1+18+4+23+15+18+11 = 98%
    Knowledge K+N+O+W+L+E+D+G+E
    11+14+15+23+12+5+4+7+5 = 96%
    Love
    L+O+V+E
    12+15+22+5 = 54%
    Luck L+U+C+K
    12+21+3+11 = 47%
    most of us think this is the most important ??? )
    Then what makes 100% ?
    Is it Money ? .. NO ! ! !
    M+O+N+E+Y
    13+15+14+5+25 = 72%
    Leadership ? .... NO ! ! !
    L+E+A+D+E+R+S+H+I+P
    12+5+1+4+5+18+19+9+16 = 89%
    Every problem has a solution, only if we perhaps change our attitude.
    To go to the top,
    to that 100% ,
    what we really need to go further... a bit more...
    ATTITUDE A+T+T+I+T+U+D+E 1+20+20+9+20+21+4+5 = 100%
    It is OUR ATTITUDE towards Life and Hard Work that makes OUR Life very close to 100% Success! ! !
    ATTITUDE matter...

    Digital rights mgmt : remove-DRM-protection

    Well this is definitely not about one of those xRM solutions that Dynamics CRM Team boasts about.. he.. he.. (in case u saw their video)

    Digital rights mgmt. technology limits on how users may make and distribute copies of digital files and physical media like CDs/DVDs. nothing new and interesting.. ;-)

    But its just that came across a few solutions/products from MS that i thought i will share you with.. :-) 

    The Windows Media DRM tech. got started in 1999 and is adopted in computing as well as in consumer electronics ind. namely by Nokia, Motorola, Verizon Wireless, and NTT DoCoMo. Recently MS came up with MS PlayReady which is more than what a DRM does. It caters to mobile ind. also and other than microsoft audio/video formats, it also supports games, ringtones, images, etc. And a typical MS PlayReady ecosystem looks like this:

    clip_image002

    Microsoft PlayReady supports wide rage of business model subscription scenarios with flat rate to access any and all content under 3 diff. mechanism i.e. timely subscribtion renewal, metering and license chaining. It also supports pay-per-view scenarios, pay-per-track scenarios, rental scenarios by supporting time-based licenses, gifting scenarios like one person effectively paying for another person to accessing content.

    Also it has wide range of content distribution options like basic progressive downloads, streaming, side loading from PC to mobile, MMS, WiFi, bluetooth sync., etc

    So if it interests you.. do go and read more abt. it here...

    Why i 'm just talking abt. only MS based ones?? its like asking why lowest dangling fruits are plucked first.. ;-p

    technically they are always easy to install, deploy and use.. just do next, next and next.. but yes the same doesn't go well as far as price is concerned (its costing approx $30000 for the SDK and $30000 per processor for service deployment license)

    So then out of curiosity i just bing'ed (not googled.. :) to see how easy is it to crack DRM protected files.. and i found plenty of such tools that too FREE!!!

    http://undrm.info/remove-DRM-protection/

    http://www.instantfundas.com/2008/01/how-to-remove-drm-from-media-files.html

    not sure if these tools do work what they claim to and whether PlayReady managed content will crack proof???

    Happy Reading...

    even if question remains open on whether To DRM or Not to DRM!!! ;-)

    HTTP protocol based progressive streaming

     

    In its efforts to provide streaming services, M$ has come long way as from NetShow Services under Windows NT 4.0 to Windows Media Services 2008 to smooth-streaming under IIS7.

    So you see a very gradual shift from traditional streaming protocols (RTSP, MMS, RTMP, etc.) to basic HTTP protocol based progressive streaming to now what is called as adaptive streaming which is enabled in IIS7 by installing Smooth Streaming IIS extension and a similar product by Move Networks' Adaptive Stream.

    The HTTP based progressive streaming is widely used by YouTube and many similar video sharing sites. Even though its has benefits over traditional streaming protocols, but it has its own disadvantages which is very much addressed by adaptive/smooth streaming (won't bore u lot, so leaving up to u to find/read it.. he.. he..)

    There is a nice demo uploaded at http://www.iis.net/media/experiencesmoothstreaming which show how smooth-streaming dynamically detects current network and local PC conditions, and based on it switches the video quality that Silverlight client plays.

    To prove this new power of IIS, M$ did coverage for Democratic National Convention under its SilverLight client framework at http://gallery1.demconvention.com/ (u might hv to download MoveNetworks' player too) and later again did it for 2008 Beijing Summer Olympic Games at http://www.nbcolympics.com/video/ (though now you will have to search for it there as they are now getting ready for 2010 Winter Olympic Games in Vancouver ;-)

    Then again M$ also teamed with Akamai to show case some of the best HD quality videos at http://www.smoothhd.com/

    To encode such smooth-streaming videos MS Expression Encoder 2 (SP1) can be used, which has built-in templates too to enable smooth-streaming in any SilverLight app. So you, the flash lover designer, get up, jagooo, bcoz its time learn few new tools... ;-p

    Its quiet interesting to understand how this adaptive streaming works and the benefits/complexities that comes with it, so do read more about it...

    Happy Streaming!!!

    ;-)

    Wednesday, September 16, 2009

    Page not found using ASP.NET Development server

    When You create a web site and try to debug it visual studio opens the browser at a different port than the development server runs at. When You try to run any project you receive "Page not found" in browser opened by ASP.NET Development server.

    here is its fix,

    as u have Eset nod32 antivirus v3.0.621 (same as me) , the problem is from this AV that dont allow connections to be made to Visual Studio ASP.NET Server .

    now follow these steps to solve this issue:

    1.DoubleClick on Nod32 icon on tray and Open it up.
    2.if it is not in "Advanced Mode" , switch to Advanced Mode. ( you can do it by clicking on the bottom-left link "Display:Standard Mode" and then click on "Toggle Advanced Mode" )
    3.then goto SETUP section. then on the Right Pane click on "Antivirus and Antispyware protection". the panel should be opened.
    4.now in the "Web Access protection" click on "Configure..."
    5.from the left Tree go to path : "Web access protection > HTTP > Web Browsers"
    6.now you should see visual studio 8 "devenv.exe" in the list .
    7.click on it twice till you see a cross sign in the box. ( Note on CROSS sign , not mark sign ! )
    8.with this cross sign you tell the Nod32 that this program should not be scanned and filtered for web access.
    due to this steps , my problem solved and now i can access my page from localhost: .

    Wednesday, August 26, 2009

    Jquery API/1.3/Utilities

    API/1.3/Utilities

    From jQuery JavaScript Library

    Jump to: navigation, search

    Browser and Feature Detection:

    Name

    Type

    jQuery.support

    Returns: Object

    Added in jQuery 1.3 A collection of properties that represent the presence of different browser features or bugs.

    jQuery.browser

    Returns: Map

    Deprecated in jQuery 1.3 (see jQuery.support) Contains flags for the useragent, read from navigator.userAgent.

    jQuery.browser.version

    Returns: String

    Deprecated in jQuery 1.3 (see jQuery.support) The version number of the rendering engine for the user's browser.

    jQuery.boxModel

    Returns: Boolean

    Deprecated in jQuery 1.3 (see jQuery.support) States if the current page, in the user's browser, is being rendered using the W3C CSS Box Model.

    Array and Object operations:

    Name

    Type

    jQuery.each( object, callback )

    Returns: Object

    A generic iterator function, which can be used to seamlessly iterate over both objects and arrays. Arrays and array-like objects with a length property (such as a function's arguments object) are iterated by numeric index, from 0 to length-1. Other objects are iterated via their named properties.

    jQuery.extend( deep, target, object1, objectN )

    Returns: Object

    Extend one object with one or more others, returning the modified object.

    jQuery.grep( array, callback, invert )

    Returns: Array

    Finds the elements of an array which satisfy a filter function. The original array is not affected.

    jQuery.makeArray( obj )

    Returns: Array

    Turns anything into a true array.

    jQuery.map( array, callback )

    Returns: Array

    Translate all items in an array to another array of items.

    jQuery.inArray( value, array )

    Returns: Number

    Determine the index of the first parameter in the Array (-1 if not found).

    jQuery.merge( first, second )

    Returns: Array

    Merge two arrays together.

    jQuery.unique( array )

    Returns: Array

    Remove all duplicate elements from an array of elements. Note that this only works on arrays of DOM elements, not strings or numbers.

    Test operations:

    Name

    Type

    jQuery.isArray( obj )

    Returns: Boolean

    Added in jQuery 1.3 Determine if the parameter passed is an array.

    jQuery.isFunction( obj )

    Returns: Boolean

    Determine if the parameter passed is a Javascript function object.

    String operations:

    Name

    Type

    jQuery.trim( str )

    Returns: String

    Remove the whitespace from the beginning and end of a string.

    URLs:

    Name

    Type

    jQuery.param( obj )

    Returns: String

    Serializes an array of form elements or an object (core of .serialize() method).

    Tuesday, August 18, 2009

    Caffeine :: Google's answer to Microsoft's Bing!!!!

    Its still in its beta, running at below link.

    It claims to be faster than its classic ver., much accurate and subjective with new algo

    http://www2.sandbox.google.com/

    On 40th anniversary of apollo 11 mission

    Whether that trip was actually faked or not nobody knows but this website has a real-time simulation of that entire Apollo 11 mission, divided into 11 phases with 103 hours of audio from NASA tapes. Animation really cool... check it out here at

    http://www.wechoosethemoon.org/

    Friday, May 29, 2009

    How to Create A Sliding Panel with Jquery

    We are going to show you a series of how to articles to create some jQuery effects with JavaScript in your web designs. In case you don’t know what jQeury is, it’s a JavaScript Library. It has heaps of Ajax and JavaScript components that will let you enhance your web design and the users experience on your site.

    First you need to grab a copy of jQuery Grab the latest released mini(compressed) version.

    How to get the elements you need.

    Creating jQuery Functions is relatively easy thank to the great documentation. The main thing you have to know is how to get the exact element that you want to apply the effects to.

    Example :


    * $(”#header”) = get the element with id=”header”
    * $(”h3″) = get all <h3> element
    * $(”div#content .photo”) = get all element with class=”photo” nested in the <div id=”content”>
    * $(”ul li”) = get all <li> element nested in all <ul>
    * $(”ul li:first”) = get only the first <li> element of the <ul>

    So with that in mind we are going to create our first jQuery effect. The commonly seen sliding panel, where you click a button and a panel slides up or down. Create a html document and call in the JavaScript file between the <head> tags along with you css file for styling. Then create two divs, one big one called <div id=”panel”></div> for the pannel and <div class=”btn-slide”></div> for the button. Style as you wish.

    Then call is javascript into your page either inline, or by an external .js file.






    When any element with in your html file is clicked, it will toggle the slide up and down of the <div id=”panel”> element and then toggle a CSS class=”active” to the <a class=”btn-slide”> element. The .active class will toggle the background position of the arrow image (by CSS).

    what is jquery

    jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript.

    it's lightweight (just 19 kb in size) CSS3 complient and with cross browser support (IE 6.0+, FF 2+, Safari 3.0+, Opera 9.0+, Chrome and almost all the browsers).

    you can download the latest release from here

    Missing Dynamic Data Templates - VS 2008 SP1 and .NET 3.5 SP1

    In case you have installed the .NET 3.5 SP1 and Visual Studio 2008 SP1 and are unable to find the Dynamic Data Website Template, you can install the latest version of the runtime from here

    If you are unable to find the "Dynamic Data Website" Template than instead of fixing the issue by installing/uninstalling SP1 Bits again, it is better to install the latest bits of the Dynamic Data Runtime from CodePlex. this will install the template and the other advantage is that, you will also get the "Dynamic Data Website Wizard (Preview)" that allows you to configure a data driven website very quickly, by following the wizard steps.

    Happy Coding :-)

    ASP.Net Dynamic Data Web Site

    If your web site is heavily data driven then here is a quick and easy way for you to create one without writing much code. All you need is Visual Studio 2008 SP1 or Visual Web Developer 2008 Express SP1 installed on your box.

    Dynamic Data Web Sites makes use of a mechanism called Scaffolding. When Scaffolding is enabled it lets ASP.Net go through your data model and generate web pages for your tables. These generated pages have Insert, Delete and Update capabilities for each table.

    ASP.NET Dynamic Data Web Sites provides a framework that enables you to quickly build a functional data-driven application, based on a LINQ to SQL or Entity Framework data model. It also adds great flexibility and functionality to the DetailsView, FormView, GridView, and ListView controls in the form of smart validation and the ability to easily change the display of these controls using templates.

    ASP.NET Dynamic Data brings major usability and RAD development changes to the existing ASP.NET data controls. RAD development is significantly increased by the use of a rich scaffolding framework. After you add a LINQ to SQL or Entity Framework data model to a project, you can simply register it with Dynamic Data. The result is a fully functional Web site. Full CRUD (create, read, update, and delete) operations are supported. The site includes filtering by foreign keys and Boolean fields; foreign keys are automatically converted to their friendly names. Smart validation is automatically available, which provides validation based on database constraints for nullable fields, data type, and field length.

    The DetailsView and GridView controls have been extended to display fields by using templates instead of by using hard-coded rules that are programmed in the controls. These templates are part of the project, and you can customize them to change their appearance or to specify which controls they use for rendering. This makes it very easy to make a change in one place in your site that specifies how to present dates for editing, as one example. FormView and ListView controls can implement similar behavior by using a DynamicControl object in their templates and by specifying which field in the row to display. Dynamic Data will then automatically build the UI for these controls based on the templates that you specify.

    Validation is significantly improved in the controls as well. The controls read metadata for a LINQ to SQL or Entity Framework data model and provide automatic validation based on the model. For example, if a column in the database is limited to 50 characters, and if a column is marked as not nullable, a RequiredFieldValidator control is automatically enabled for the column. (The controls also automatically support data-model-level validation.) You can apply other metadata to take further control over display and validation.

    Here are some Links to start with :

    Getting Started with Dynamic Data

    Begin Modifying Dynamic Data Applications with URL Routing

    Begin Editing the Templates in ASP.NET Dynamic Data Applications

    Enable In-Line Editing in ASP.NET Dynamic Data Applications

    Or a blog post by Reshmi Mangalore at msdn blogs


    Try this today and have fun!

    Friday, March 27, 2009

    How to open Excel XLS file in C#.net

    Suppose you have an excel file that contains the data and you wish to use the same The following code snippet will read the file and return it in a dataset now you are free to use this dataset for your purpose.



    static DataSet readExcel()
    {
    string filename = "";
    string sheetname = "";
    filename = "";
    sheetname = "";
    OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filename + ";Extended Properties=Excel 8.0");
    con.Open();
    DataSet myDataSet = new DataSet();
    OleDbDataAdapter myCommand = new OleDbDataAdapter(" SELECT * FROM ["+sheetname+"$]", con);
    myCommand.Fill(myDataSet);
    con.Close();
    return myDataSet;
    }

    Monday, March 9, 2009

    Writing recursive queries in sql server 2000/2005

    In SQL Server 2000 there is no simple way to create recursive queries that have several levels of data (hierarchical data). Generally a recursive query is needed when you have a parent and child data stored in the same table. One example may be employee data where all employee data is stored in one Employee table and there is an indicator that specifies the employees supervisor that points back to another record in the same table. This is done quite often for other data as well.

    To query this data to find the employee and supervisor is pretty easy. The query would be:



    SELECT e1.EmpId, e1.FirstName, e1.LastName,
    e1.SupervisorID, e2.FirstName AS SupFirstName, e2.LastName
    AS SupLastNameFROM Employee e1 LEFT JOIN Employee e2
    ON e1.SupervisorID = e2.EmpId

    So you can see this is pretty simple to just get this level of data, but what if you want to find out all of the direct and indirect reports of a particular employee.

    C programmers use recursive programming techniques for traversing tree structures. The same can be implemented in T-SQL using recursive stored procedure calls.

    Consider the employee table of an organization, that stores all the employee records. Each employee is linked to his/her manager by a manger ID. This table can be represented using the following CREATE TABLE statement:



    CREATE TABLE dbo.Emp
    (
    EmpID int PRIMARY KEY,
    EmpName varchar(30),
    MgrID int FOREIGN KEY REFERENCES Emp(EmpID)
    )

    Notice that, EmpID is decalred as a primary key, and the MgrID column is declared as a foreign key constraint, that references the EmpID column of the same table, that is, a self referencing table. This is so, because all employees and managers are stored in the same table.

    Now what all we need is a stored procedure that calls itself recursively. You should be aware of a limitation imposed by SQL Server though. A stored procedure can nest itself upto a maximum of 32 levels. If you exceed this limit, you will receive the following error:
    Server: Msg 217, Level 16, State 1, Procedure , Line 1 Maximum stored procedure nesting level exceeded (limit 32).

    The SQL server 2005 microsoft come up with Common Table Expressions for writing Recursive queries.

    A common table expression (CTE) provides the significant advantage of being able to reference itself, thereby creating a recursive CTE. A recursive CTE is one in which an initial CTE is repeatedly executed to return subsets of data until the complete result set is obtained.


    A query is referred to as a recursive query when it references a recursive CTE. Returning hierarchical data is a common use of recursive queries, for example: Displaying employees in an organizational chart, or data in a bill of materials scenario in which a parent product has one or more components and those components may, in turn, have subcomponents or may be components of other parents.


    A recursive CTE can greatly simplify the code required to run a recursive query within a SELECT, INSERT, UPDATE, DELETE, or CREATE VIEW statement. In earlier versions of SQL Server, a recursive query usually requires using temporary tables, cursors, and logic to control the flow of the recursive steps.

    recursive CTE in Transact-SQL is similar to recursive routines in other programming languages. Although a recursive routine in other languages returns a scalar value, a recursive CTE can return multiple rows.


    A recursive CTE consists of three elements:
    1. Invocation of the routine.

    The first invocation of the recursive CTE consists of one or more CTE_query_definitions joined by UNION ALL, UNION, EXCEPT, or INTERSECT operators. Because these query definitions form the base result set of the CTE structure, they are referred to as anchor members.CTE_query_definitions are considered anchor members unless they reference the CTE itself. All anchor-member query definitions must be positioned before the first recursive member definition, and a UNION ALL operator must be used to join the last anchor member with the first recursive member.
    2. Recursive invocation of the routine.

    The recursive invocation includes one or more CTE_query_definitions joined by UNION ALL operators that reference the CTE itself. These query definitions are referred to as recursive members.
    3. Termination check.

    The termination check is implicit; recursion stops when no rows are returned from the previous invocation.

    The recursive CTE structure must contain at least one anchor member and one recursive member. The following pseudocode shows the components of a simple recursive CTE that contains a single anchor member and single recursive member.


    WITH cte_name ( column_name [,...n] )
    AS
    (
    CTE_query_definition –- Anchor member is defined.
    UNION ALL
    CTE_query_definition –- Recursive member is defined referencing cte_name.
    )
    -- Statement using the CTE
    SELECT * FROM cte_name

    Example:

    The following example shows the semantics of the recursive CTE structure by returning a hierarchical list of employees, starting with the highest ranking employee, in the company. The statement that executes the CTE limits the result set to employees in the Research and Development Group.



    WITH DirectReports (ManagerID, EmployeeID, Title, DeptID, Level)
    AS
    (-- Anchor member definition
    SELECT e.ManagerID, e.EmployeeID, e.Title, edh.DepartmentID,
    0 AS Level FROM HumanResources.Employee AS e INNER JOIN HumanResources.EmployeeDepartmentHistory AS edh
    ON e.EmployeeID = edh.EmployeeID AND edh.EndDate IS NULL WHERE ManagerID IS NULL
    UNION ALL
    -- Recursive member definition
    SELECT e.ManagerID, e.EmployeeID, e.Title, edh.DepartmentID, Level + 1 FROM HumanResources.Employee AS e
    INNER JOIN HumanResources.EmployeeDepartmentHistory AS edh
    ON e.EmployeeID = edh.EmployeeID AND edh.EndDate IS NULL INNER JOIN DirectReports AS d
    ON e.ManagerID = d.EmployeeID)
    -- Statement that executes the CTE
    SELECT ManagerID, EmployeeID, Title, LevelFROM DirectReportsINNER JOIN HumanResources.Department AS dp ON DirectReports.DeptID = dp.DepartmentID
    WHERE dp.GroupName = N'Research and Development' OR Level = 0;

    Monday, February 9, 2009

    Transaction Recovery

    Every Microsoft® SQL Server™ 2000 database has a transaction log that records data modifications made in the database. The log records the start and end of every transaction and associates each modification with a transaction. An instance of SQL Server stores enough information in the log to either redo (roll forward) or undo (roll back) the data modifications that make up a transaction. Each record in the log is identified by a unique log sequence number (LSN). All of the log records for a transaction are chained together.

    An instance of SQL Server records many different types of information in the transaction log. Instances of SQL Server 2000 primarily log the logical operations performed. The operation is reapplied to roll forward a modification, and the opposite of the logical operation is performed to roll back a modification.

    Each instance of SQL Server controls when modifications are written from its data buffers to disk. An instance of SQL Server may cache modifications in buffers for a period of time to optimize disk writes. A buffer page that contains modifications that have not yet written to disk is known as a dirty page. Writing a dirty buffer page to disk is called flushing the page. When modifications are cached, care must be taken to ensure that no data modification is flushed before the corresponding log image is written to the log file. This could create a modification that could not be rolled back if necessary. To ensure that they can recover all modifications, instances of SQL Server use a write-ahead log, which means that all log images are written to disk before the corresponding data modification.

    A commit operation forces all log records for a transaction to the log file so that the transaction is fully recoverable even if the server is shut down. A commit operation does not have to force all the modified data pages to disk as long as all the log records are flushed to disk. A system recovery can roll the transaction forward or backward using only the log records.

    Periodically, each instance of SQL Server ensures that all dirty log and data pages are flushed. This is called a checkpoint. Checkpoints reduce the time and resources needed to recover when an instance of SQL Server is restarted. For more information on checkpoint processing, see Checkpoints and the Active Portion of the Log.

    Rolling Back an Individual Transaction
    If any errors occur during a transaction, the instance of SQL Server uses the information in the log file to roll back the transaction. This rollback does not affect the work of any other users working in the database at the same time. Usually, the error is returned to the application, and if the error indicates a possible problem with the transaction, the application issues a ROLLBACK statement. Some errors, such as a 1205 deadlock error, roll back a transaction automatically. If anything stops the communication between the client and an instance of SQL Server while a transaction is active, the instance rolls back the transaction automatically when notified of the stoppage by the network or operating system. This could happen if the client application terminates, if the client computer is shut down or restarted, or if the client network connection is broken. In all of these error conditions, any outstanding transaction is rolled back to protect the integrity of the database.

    Recovery of All Outstanding Transactions at Start-up
    It is possible for an instance of SQL Server to sometimes stop processing (for example, if an operator restarts the server while users are connected and working in databases). This can create two problems:


    • There may be an unknown number of SQL Server transactions partially completed at the time the instance stopped. These incomplete transactions need to be rolled back.

    • There may be an unknown number of data modifications recorded in the SQL Server database log files, but the corresponding modified data pages were not flushed to the data files before the server stopped. Any committed modifications must be rolled forward.

    When an instance of SQL Server is started, it must find out if either of these conditions exist and address them. The following steps are taken in each SQL Server database that is in the instance:


    1. The LSN of the last checkpoint is read from the database boot block along with the Minimum Recovery LSN.
    2. The transaction log is scanned from the Minimum Recovery LSN to the end of the log. All committed dirty pages are rolled forward by redoing the logical operation recorded in the log record.
    3. The instance of SQL Server then scans backward through the log file rolling back all uncompleted transactions by applying the opposite of the logical operation recorded in the log records.
    The RESTORE statement also uses this type of recovery, unless a user specifies the NORECOVERY option. When restoring a sequence of database, differential, or log backups to recover a database to a point of failure, you specify NORECOVERY on all RESTORE statements except when restoring the last log backup. When the last backup in the sequence is restored, the RESTORE statement also has to ensure that all uncompleted transactions are rolled back. You specify the RECOVERY option on this RESTORE statement, in which case it uses the same logic as the startup recovery process to roll back all transactions that are still marked incomplete at the end of the last log.

    Friday, January 23, 2009

    How to perform case sensitive searches in SQL Server?

    A default SQL Server installation is case insensitive, which means that SQL Server will not differentiate between upper and lower case characters/letters. That is, "Magic" is the same as "MAGIC" or "magic".
    Let’s see why one would want to perform case sensitive searches. One classic example is password comparisons. People use a combination of upper and lower case (mixed case) characters in their passwords, just to make the passwords difficult to guess. But there is no point in doing that, if the database disregards the case.
    To keep the users happy, and their passwords secure, programmers prefer case sensitive comparisons in this case.
    So we can achieve the goal by Converting data to binary type before comparison:When you convert a character to binary or varbinary datatype, that character's ASCII value gets represented in binary. Since, 'A' and 'a' have different ASCII values, when you convert them to binary, the binary representations of these values don't match, and hence the case sensitive behavior.
    Example :



    IF EXISTS
    (SELECT 1 FROM AuthenticCustomers
    WHERE CAST(UserID AS varbinary(20)) = CAST( AS varbinary(20))
    AND CAST(User_Password AS varbinary(25)) = CAST( AS varbinary(25)))

    BEGIN
    PRINT 'Authentic User'
    END
    ELSE
    BEGIN
    PRINT 'Invalid User or Password'
    END