Pages

Showing posts with label Microsoft. Show all posts
Showing posts with label Microsoft. Show all posts

Tuesday, 4 October 2011

Edit In Place Plugin Using jQuery

Edit In Place means : User clicks text on web page. Block of text becomes a form. User edits contents and presses submit button. Changes are sent via JavaScript which normally would be used to update the text and save it. Form becomes normal text again.

image

Demo using MVC Application:

1- First you must add jQuery , plugin and style sheet to _Layout.cshtml file.

<head>

    <title>@ViewBag.Title</title>

    <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />

    <link href="../../StyleSheet.css" rel="stylesheet" type="text/css">

    <script src="@Url.Content("~/Scripts/jquery-1.6.4.js")" type="text/javascript"></script>

    <script src="@Url.Content("~/Scripts/jquery-1.6.4.min.js")" type="text/javascript"></script>

    <script src="@Url.Content("~/Scripts/EditableText.js")" type="text/javascript"></script>

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>

    @RenderSection("head", required: false)

</head>

2- Pass the elements you want to make editable to the plugin. In this example I marked editable elements with "editableText" class.

<p class="editableText">

When you roll your cursor over the element , the background changes to a dashed darkorange line.

3- Looks for the div with id=”editableText” and tells jQuery to do something when the div is clicked. (Make the new line is not allowed )

jQuery(function ($) {
           $('p.editableText').editableText({
               newlinesEnabled: false
           });

           $.editableText.defaults.newlinesEnabled = true;

           $('div.editableText').editableText();

           $('.editableText').change(function () {
               var newValue = $(this).html();
           });
       });

Clicking the text will start some DOM (Document Object Model) magic resulting in the element being replaced by a textarea input — with the text to be edited inside.

In a real world application you would add in some additional safety checks, and then update your database with the new information and send back information that tells jQuery if the changes were successful.

4- Create a function that will do something with the new value of the editable element. Bind it to the element using change event. (Edit, Save and cancel events)

var editEl = buttons.find('.edit').click(function () {
                startEditing();
                return false;
            });

            buttons.find('.save').click(function () {
                stopEditing();
                editable.trigger(options.changeEvent);
                return false;
            });

            buttons.find('.cancel').click(function () {
                stopEditing();
                editable.html(prevValue);
                return false;
            });

check the “EditableText.js” file

 

See all the Demo code : Download

 

Useful Links :

- http://plugins.jquery.com/project/edit_in_place

- http://plugins.jquery.com/plugin-tags/edit-place


Saturday, 27 August 2011

Introduction for Microsoft Visual Studio LightSwitch

 

Microsoft Visual Studio LightSwitch is a simplified self-service development tool that enables you to build business applications quickly and easily for the desktop and cloud.

image5

LightSwitch offers downloadable starter kits and flexible deployment options that help you create and easily release custom business apps that look professional and polished, with no coding required.

LightSwitch includes customizable templates and enables you to write custom business logic that applies to your organization’s specific needs, helping you create an experience that your users will love.

Easily expand your LightSwitch application’s functionality by adding extensions and components from third-party vendors.

Now you can see firsthand why building business apps has never been easier. Download the free 90-day Trial , watch the LightSwitch Launch Keynote and get general product information on the LightSwitch site

Video:  Build your first LightSwitch app

To Discover the Top 10 Benefits of Visual Studio LightSwitch and compare it with Visual Studio Pro Download the LightSwitch datasheet .

Microsoft Visual Studio Lightswitch 2011 [X86 - LULZ ISO]

kindly Wait for the coming posts related to LightSwitch

Thursday, 25 August 2011

Microsoft Web Platform Installer

Microsoft Web Platform Installed is a simple.

It’s a free tool that makes you can download and install all of Microsoft's entire web platform in one step using the Web Platform Installer’s user interface including :-

  1. IIS
  2. Visual Web Designer
  3. SQL Server 2008 Express Edition
  4. Microsoft .Net Framework
  5. Silverlight Tools
  6. and more ……

You can choose to install either specific products or the entire Microsoft Web Platform onto your computer.

The Web PI also helps keep your products up to date by always offering the latest additions to the Web Platform.

Web PI 1.0 supports Windows XP, Windows 2003, Windows Vista and of course Windows 2008.

Web PI 3.0 supports Windows 7, Windows Vista SP2, Windows XP SP3+, Windows Server 2003 SP2+, Windows Server 2008, Windows Server 2008 R2.

Download Web PI 3.0

Web PI starts up on the "Spotlight" tab, where we highlight products and applications that we think will be the most interesting for our users

web-platform-installerFigure 1: “Web PI Spotlight” tab

 

Web PI separates the components you can install into two main categories:  Products and Applications.

In the Products tab, you will find all the components you need to build and maintain your web sites.  The Applications tab is home to our wide collection of open-source applications that you can use as a great starting place for developing your sites.

 

The “Products” tab shows the four main components: Server, Frameworks, Database and Tools.

IC477051

Figure 2: “Products” tab

Wednesday, 24 August 2011

Windows 8

 

Windows 8 new features !!!!!

Introduces Windows 8

 

Windows 8 interface, navigation features

 

Building Windows 8 news features copy move rename delete

They wanted to do an early Windows 8 post about one of the most used features, and one They have not improved substantially in a long time. With the increasing...

 

 

USB 3.0 in Windows 8

 

 

Windows 8 Video Preview

Saturday, 2 April 2011

What is the difference between SharePoint Document library and SharePoint List?


SharePoint Document Library :


1- SharePoint library is really for holding documents, files, and images etc. in similar way to how a regular folder on a shared network drive does. For this reason, libraries allow you to set up templates for common types of document and also give the option of version control so that you can track any revisions.


1DocumentLibrarySettings


SharePoint List:


1- It is best thought of as mini-databases.


2- A list will allow you to store a number of items such as KPIs, tasks, events, staff details etc. in a similar way to how MS Excel or MS Access will.


3- The beauty of SharePoint's lists, is that you can make quick work of building a simple database (with its own, customizable, data entry forms) in a matter of minutes and without any coding. You can also choose which fields to include (title, reference number, status, date etc.) or create your own by creating a new content type and then adding custom columns to it.

Save Site as a template and using it in MS SharePoint 2007

If you want to quickly recreate the design, structure, or content of a site, you can save the site as a site template that you can then choose when you create a new site. To save a site as a template, do the following:

On the Site Actions menu Site Actions menu, click Site Settings:


1- On the Site Settings page, in the Look and Feel section, click Save site as template.


01_in_wss_sites_when_you_go_to_site_settings_page_this_is_how_your_look_a


2- On the Save Site as Template page, in the File Name section, type a name for the template file.


3- In the Name and Description section, type a name and optionally a description.


SaveSiteAsTemplate


4- In the Include Content section, select the Include Content check box if you want new Web sites created from this template to include the contents of all lists and document libraries in the Web site.


Note Some customizations, such as custom workflows, are present in the template only if you choose to include content. Including content can increase the size of your template. The size limit for Include Content is 10 megabytes (MB).

5- Click OK.


The next time you create a site, the site template will appear in the list of available site templates.

Friday, 1 April 2011

Alter Microsoft SQL Server 2008 Table in Design Mode

This article is not about sharing some programming ideas / concepts and some excellent code snippets. It's about sharing the necessary settings that you need to change to work in design mode simply as you did in Microsoft SQL Server 2008 because we can’t alter Microsoft SQL Server 2008 Object (design mode).

ImageA

Image A

 

Solution Steps :

1- Open Microsoft SQL Server Management Studio 2008 ,Click on the tools menu and select Options.A window will appear with the various SQL Server settings options.

2- Select the Designers node and after that, click on the Tables and Database Designer sub node. Here you will find some option of a Table. The following image - B shows the general options of SQL Server database Table object.

ImageB

Image B

3- You will find a checkbox (marked in orange color) named “Prevent saving changes that require table re-creation”. By default, the value of the checkbox is checked. You just need to uncheck the checkbox, that’s all.

Note: you can see this link for more info http://support.microsoft.com/kb/956176

Sunday, 30 January 2011

SQL Server 2005 Paging - The Holy Grail

Introduction

The paging and ranking functions introduced in 2005 are old news by now, but the typical ROW_NUMBER OVER() implementation only solves part of the problem.

Nearly every application that uses paging gives some indication of how many pages (or total records) are in the total result set. The challenge is to query the total number of rows, and return only the desired records with a minimum of overhead? The holy grail solution would allow you to return one page of the results and the total number of rows with no additional I/O overhead.

In this article, we're going to explore four approaches to this problem and discuss their relative strengths and weaknesses. For the purposes of comparison, we'll be using I/O as a relative benchmark.

The 'two-bites' approach

The most basic approach is the 'two-bites' approach. In this approach you, effectively, run your query twice; querying the total rows in one pass, and querying your result set in the second. The code is pretty straightforward:

DECLARE @startRow INT ; SET @startrow = 50 
SELECTCOUNT(*) AS TotRows 
FROM [INFORMATION_SCHEMA].columns

;WITH cols 
AS 

SELECT table_name, column_name, 
  ROW_NUMBER() OVER(ORDER BY table_name, column_name) AS seq 
  FROM [INFORMATION_SCHEMA].columns 

SELECT table_name, column_name 
FROM cols 
WHERE seq BETWEEN @startRow AND @startRow + 49 
ORDERBY seq

It gives the desired results, but this approach doubles the cost of the query because you query your underlying tables twice:

(1 row(s) affected) 
Table 'Worktable'. Scan count 0, logical reads 0, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0. 
Table 'syscolpars'. Scan count 1, logical reads 46, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0. 
Table 'sysschobjs'. Scan count 1, logical reads 34, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0. 
(50 row(s) affected) 
Table 'Worktable'. Scan count 0, logical reads 0, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0. 
Table 'syscolpars'. Scan count 1, logical reads 46, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0. 
Table 'sysschobjs'. Scan count 1, logical reads 34, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

The temp table approach

The 'two-bites' approach is especially undesirable if your paged query is very expensive and complex. A common workaround is to write the superset into a temporary table, then query out the subset. This is also the most common way to implement paging pre-2005 (in this case, ROW_NUMBER is superfluous).

DECLARE @startRow INT ; SET @startrow = 50 
CREATETABLE #pgeResults( 
  id INT IDENTITY(1,1) PRIMARY KEY CLUSTERED, 
  table_name VARCHAR(255), 
  column_name VARCHAR(255) 

INSERTINTO #pgeResults(Table_name, column_name) 
SELECT table_name, column_name 
FROM [INFORMATION_SCHEMA].columns 
ORDERBY [table_name], [column_name] 
SELECT@@ROWCOUNT AS TotRows 
SELECT Table_Name, Column_Name 
FROM #pgeResults 
WHERE id between @startrow and @startrow + 49 
ORDERBY id

DROPTABLE #pgeResults

Looking at the query plan, you can see that your underlying tables are queried only once but the I/O stats show us that you take an even bigger hit populating the temporary table.

Table '#pgeResults_________________________________________________________________________________________________________000000001A9F'. Scan count 0, logical reads 5599, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0. 
Table 'Worktable'. Scan count 0, logical reads 0, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0. 
Table 'syscolpars'. Scan count 1, logical reads 46, physical reads 0, read-ahead reads 14, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0. 
Table 'sysschobjs'. Scan count 1, logical reads 34, physical reads 0, read-ahead reads 39, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0. 
(2762 row(s) affected) 
(1 row(s) affected) 
(50 row(s) affected) 
Table '#pgeResults_________________________________________________________________________________________________________000000001A9F'. Scan count 1, logical reads 3, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

In this case, it would be better to query the tables twice. Maybe some new 2005 functionality can yield a better solution.

The COUNT(*) OVER() Approach

OVER() can also be used with Aggregate Window Functions. For our purposes this means we can do a COUNT(*) without the need for a GROUP BY clause, returning the total count in our result set. The code definitely looks much cleaner and, if your application permits it, you can simply return one dataset (eliminating the overhead of writing to a temp table).

DECLARE @startRow INT ; SET @startrow = 50 
;WITH cols 
AS 

SELECT table_name, column_name, 
  ROW_NUMBER() OVER(ORDER BY table_name, column_name) AS seq, 
COUNT(*) OVER() AS totrows 
  FROM [INFORMATION_SCHEMA].columns 

SELECT table_name, column_name, totrows 
FROM cols 
WHERE seq BETWEEN @startRow AND @startRow + 49 
ORDERBY seq

Unfortunately this approach has it's own hidden overhead: 
Table 'Worktable'. Scan count 3, logical reads 5724, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0. 
Table 'syscolpars'. Scan count 1, logical reads 46, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0. 
Table 'sysschobjs'. Scan count 1, logical reads 34, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

Where did that come from? In this case, SQL Server implements the COUNT(*) OVER() by dumping all the data into a hidden spool table, which it then aggregates and joins back to your main output. It does this to avoid re scanning the underlying tables. Although this approach looks the cleanest, it introduces the most overhead. 

I've spent most of today cleaning up and old data-paging proc that is both very inefficient and frequently called enough for me to notice it. I've explored probably a dozen other approaches to solving this problem before I came up with the solution below. For the sake of brevity—and because they rest are pretty obscure and equally inefficient —we'll now skip to the best solution.

The Holy Grail

In theory, ROW_NUMBER() gives you all the information you need because it assigns a sequential number to every single row in your result set. It all falls down, of course, when you only return a subset of your results that don't include the highest sequential number. The solution is to return a 2nd column of sequential numbers, in the reverse order. The total number of the records will always be the sum of the two fields on any given row minus 1 (unless one of your sequences is zero-bound).

DECLARE @startRow INT ; SET @startrow = 50 
;WITH cols 
AS 

SELECT table_name, column_name, 
  ROW_NUMBER() OVER(ORDER BY table_name, column_name) AS seq, 
  ROW_NUMBER() OVER(ORDER BY table_name DESC, column_name desc) AS totrows 
  FROM [INFORMATION_SCHEMA].columns 

SELECT table_name, column_name, totrows + seq -1 as TotRows 
FROM cols 
WHERE seq BETWEEN @startRow AND @startRow + 49 
ORDERBY seq

This approach gives us our page of data and the total number of rows with zero additional overhead! (well, maybe one or two ms of CPU time, but that's it) The I/O statistics are identical to querying just the subset of records. 
Table 'Worktable'. Scan count 0, logical reads 0, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0. 
Table 'syscolpars'. Scan count 1, logical reads 46, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0. 
Table 'sysschobjs'. Scan count 1, logical reads 34, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

Compare the stats above with the stats and query below (just returning one page of data).

;WITH cols 
AS 

SELECT table_name, column_name, 
  ROW_NUMBER() OVER(ORDER BY table_name, column_name) AS seq 
  FROM [INFORMATION_SCHEMA].columns 

SELECT table_name, column_name 
FROM cols 
WHERE seq BETWEEN @startRow AND @startRow + 49 
ORDERBY seq

Table 'Worktable'. Scan count 0, logical reads 0, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0. 
Table 'syscolpars'. Scan count 1, logical reads 46, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0. 
Table 'sysschobjs'. Scan count 1, logical reads 34, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

Conclusion

I have found this approach to be best suited for smaller resultsets from complex queries where I/O is the primary bottleneck. Jeff Moden, Peso and others here have pointed out that with larger resultsets, the I/O cost you save is more than outweighed by the CPU cost. You definitly want to compare different approches to find the best solution for your problem.

My real goal here was to try and figure out a way to avoid unnecessary I/O overhead. I am sure that this solution is not the last word on the subject and I greatly look forward to hearing your thoughts, experiences and ideas on this topic. Thank you all for reading and for your feedback.