Ramani Sandeep's Blog

DotNetting – Fast , Easy Way of Developing Applications

Archive for February, 2010

Web Page Loading in Steps – ASP.NET Solution By Petr Pechovic

Posted by Ramani Sandeep on February 23, 2010

The common scenario to reach the desired page on the internet is to write the URL to a browser and press Enter. Basically say the browser asks a server for the requested page. The server builds the page (HTML) and sends the result back to the browser. The browser displays the result to the user and makes HTTP requests to other content like images, etc. Let’s jump back to the stage when the server is building the content of the page. Some parts of the page are usually static data immediately available to use. Another data of the page could be dynamic, either from huge database heavy for calculation or from another server like RSS channel. The point is that some of the data is quickly available and some of the data need time to be loaded. The HTML build by server isn’t sending to the browser until it is completely created. That is obvious.

Read more

Hope this will help

Jay Ganesh

About these ads

Posted in ASP.NET 3.5, ASP.NET Ajax, JQuery | Tagged: | 4 Comments »

Master-Detail Views with the ASP.NET Ajax Library by Dino Esposito

Posted by Ramani Sandeep on February 22, 2010

When you think of data-driven Web pages, most of the time what you really have in mind is a master-detail view of some cross-related data. Master-detail views are ideal for rendering one-to-many relationships, and such relationships are so common in the real world that a Web platform that doesn’t provide an effective set of tools for that functionality is inadequate.

ASP.NET Web Forms has always provided strong support for data binding and a powerful set of data-source and data-bound server controls. In Web Forms, server controls do a great job of rendering hierarchies of data using nearly any possible combination of grids, lists, and drop-down boxes and supporting multiple levels of nesting.

The drawback of the views you get out of Web Forms server controls is not the effectiveness of the rendering, but the static condition.

Users who navigate within a master-detail view typically switch among master records and drill down into the details of the records that are of interest. This interaction is the essence of a master-detail view.

In a classic Web Forms scenario, each drill-down operation may trigger a postback. Many postbacks—and subsequent page reloads— are not what makes users happy these days.

An alternative exists, but it’s not free of issues either. It basically consists of preloading any possible data the user might want to see. The data is then downloaded with the standard page and kept hidden using CSS styles. At the same time, any handler of user actions is rewritten to unveil hidden content rather than triggering a postback. As you can see, this is not an easy way to go.

The ASP.NET Ajax Library, in collaboration with jQuery, offers a much more powerful toolset and makes it possible to write smooth and effective master-detail views that post back asynchronously and only when strictly needed.

Read more

Jay Ganesh

Posted in ASP.NET 4.0, JQuery | Tagged: , | 2 Comments »

Consuming WCF / ASMX / REST service using JQuery By Sridhar Subramanian

Posted by Ramani Sandeep on February 22, 2010

In this article I will explain how to consume a WCF / ASMX service using jQuery.  The scope of the article is limited to creating &  consuming different kind of services using jQuery. I have segregated this article into 7 topics based on the service consumption.

  1. Calling ASMX Web service using jQuery
  2. Calling WCF service using jQuery and retrieving data in JSON Format
  3. Calling WCF service using jQuery and retrieving data in XML Format
  4. Calling WCF service using jQuery and retrieving data in JSON Format (pass multiple input parameters) & ( Get multiple objects as output using DataContract)
  5. Calling WCF service using jQuery[ Get Method] and retrieving data in JSON Format
  6. Calling REST based WCF service using jQuery
  7. Streaming an image through WCF and request it through HTTP GET verb..

If you have never heard about jQuery or WCF or JSON, please learn it before dwelling into this article. The scope  is limited to service creation and consumption.

Read more

Hope this will help

Jay Ganesh

Posted in JQuery, WCF, Web Services | Tagged: , , , | 3 Comments »

Integrating Twitter Into An ASP.NET Website

Posted by Ramani Sandeep on February 18, 2010

If you want to integrate Twitter into your ASP.NET website there is one API called twitterizer available (Open Source).

There are some projects developed using this API. you can view that projects from here

Here is the one of the tutorial written by Scott Mitchell to explain how to use twitterizer api in asp.net

Integrating Twitter Into An ASP.NET Website By Scott Mitchell

Twitter is a popular social networking web service for writing and sharing short messages. These tidy text messages are referred to as tweets and are limited to 140 characters. Users can leave tweets and follow other users directly from Twitter’s website or by using the Twitter API. Twitter’s API makes it possible to integrate Twitter with external applications. For example, you can use the Twitter API to display your latest tweets on your blog. A mom and pop online store could integrate Twitter such that a new tweet was added each time a customer completed an order. And ELMAH, a popular open-source error logging library, can be configured to send error notifications to Twitter.

Twitter’s API is implemented over HTTP using the design principles of Representational State Transfer (REST). In a nutshell, inter-operating with the Twitter API involves a client – your application – sending an XML-formatted message over HTTP to the server – Twitter’s website. The server responds with an XML-formatted message that contains status information and data. While you can certainly interface with this API by writing your own code to communicate with the Twitter API over HTTP along with the code that creates and parses the XML payloads exchanged between the client and server, such work is unnecessary since there are many community-created Twitter API libraries for a variety of programming frameworks.

This article shows how to integrate Twitter with an ASP.NET website using the Twitterizer library, which is a free, open-source .NET library for working with the Twitter API. Specifically, this article shows how to retrieve your latest tweets and how to post a tweet using Twitterizer.

Read more

Hope this will help

Jay Ganesh

Posted in API Integration, ASP.NET | Tagged: , | 6 Comments »

Visual Studio Myth Buster

Posted by Ramani Sandeep on February 17, 2010

Microsoft has produced a Silverlight-based “Myth Busting Matrix” for Visual Studio.  This nifty web tool details the benefits of upgrading to Visual Studio 2010 and helps dispel some widely-held myths about Visual Studio and the Microsoft .NET Framework.  You can browse all three supported versions of Visual Studio (2005, 2008 and 2010) by your areas of interest and click on the myths for more information.

VSMyths

Click here to see in details

Hope this will help

Jay Ganesh

Posted in MSDN | Tagged: , , , | 2 Comments »

Redirect from Http to Https in ASP.NET

Posted by Ramani Sandeep on February 17, 2010

There are a few ways to redirect from http to https in asp.net, but I wanted a somewhat simple and efficient method.  After researching a bit, I could add some code to global.asax, or make my own custom configuration section in the web.config.  Well I chose to do a little variation of a "custom" section in the web.config.  I don’t end up creating a class that inherits from ConfigurationSection, but just a few other things.

To create a custom configuration section, here are a few links you may want to look at:

http://www.4guysfromrolla.com/articles/032807-1.aspx
http://msdn.microsoft.com/en-us/library/2tw134k3%28VS.80%29.aspx

John Mendez has recently posted a vert good article on

"How to Redirect from Http to Https in ASP.NET ? "

You can read full article here : http://www.xdevsoftware.com/blog/post/Redirect-from-Http-to-Https-in-ASPNET.aspx

Hope this will help

Jay Ganesh

Posted in ASP.NET | Tagged: | 1 Comment »

SQL SERVER – Stored Procedure Optimization Tips – Best Practices

Posted by Ramani Sandeep on February 17, 2010

Today when i read blog of Pinal Dave talking about "Stored Procedure Optimization Tips", i have found some of the very useful tips that can help us to write the SP in a such a way that it can increase the performance of the application.

Key Points discussed in the articles are :

  1. Include SET NOCOUNT ON statement
  2. Use schema name with object name
  3. Do not use the prefix “sp_” in the stored procedure name
  4. Use IF EXISTS (SELECT 1) instead of (SELECT *)
  5. Try to avoid using SQL Server cursors whenever possible
  6. Keep the Transaction as short as possible
  7. Use TRY-Catch for error handling

You can read full article here

Hope this will help

Jay Ganesh

Posted in Performance, SQL Server | Tagged: , | Leave a Comment »

The Controls collection cannot be modified because the control contains code blocks (i.e. ).

Posted by Ramani Sandeep on February 16, 2010

Today one of my team mate faced a strange problem while copying pages from one project to another.

What happen it shows the error like

"The Controls collection cannot be modified because the control contains code blocks (i.e. <% … %>)”.

The Same pages are working fine in previous place & run perfectly but after moving the pages we are facing the error shown above.

Now When i saw the error initially i thought there was problem in Ajax Control because it was redirecting me to the AjaxToolkit Base Class library javascript file.

But i was not able to figure out the problem so i typed this error in Google & got some of the solutions but the following solution by LeeDumond helped me to solve the issue i was facing.

So i decided to share it with you.

Problem

If you’re using Master Pages in ASP.NET and trying to resolve <script> or <style> references in the page head, you may have run into this this show-stopper. If so, here’s why it’s happening, and here’s an easy way to fix it.

If you’ve worked with ASP.NET Master Pages, you’ve no doubt taken advantage of automatic URL re-basing within the HtmlHead control.

Read more

 

Hope this will help

Jay Ganesh

Posted in ASP.NET Ajax | Tagged: | Leave a Comment »

Important Silverlight/WPF tutorials by Anoop Madhusudanan

Posted by Ramani Sandeep on February 16, 2010

1. Silverlight and WPF Behaviours and Triggers

The objective of this article series is to give a quick overview of Behaviors, Triggers and Actions in Silverlight and WPF. Together, they enable a great deal of design time interactivity for your UI. They also make possible re-use and re-distribution of interaction logic.

Read more

2. WPF Extensibility Hacks or WEX – Includes EventTrigger, ReactiveTrigger, InvokeMethodAction, InvokeCommandAction etc.

A set of extensibility hacks for WPF. A few interesting triggers and actions, including EventTrigger, ReactiveTrigger, InvokeMethodAction, and InvokeCommandAction. Also allows invoking Triggers and Actions based on Conditions.

Read more

3. Silverlight Experimental Hacks (SLEX) – EventTrigger, PropertyTrigger, ReactiveTrigger, InvokeMethodAction, StoryBoardAction, etc. for Silverlight

A set of Silverlight Experimental Hacks (1) A custom implementation of EventTrigger and PropertyTrigger (2) Invoking methods in your view model in MVVM (3) Conditionally invoking triggers and behaviors (4) ReactiveTrigger for exporting your custom events.

Read more

 

Hope this will Help

Jay Ganesh

Posted in WPF / Silverlight | Tagged: , , | Leave a Comment »

CheckBoxList validation using JQuery

Posted by Ramani Sandeep on February 10, 2010

Every ASP.NET developer needs validation on CheckBoxList that can be one of these two:

  1. Check for RequiredField
  2. Check for Maximum Selection Limit

Check for RequiredField

I will be using JQuery to interecept the click event of each single Checkbox inside the CheckBoxList and then update a hidden TextBox control which has a RequiredFieldValidator associated to it, when a CheckBox is clicked.

When all CheckBoxes were unselected, the hidden TextBox would have nothing in it which makes the RequiredFieldValidator throws a JavaScript message on Submit.

Listing – 1 : CheckBoxList

 <asp:CheckBoxList ID="cblBusinessType" runat="server" CssClass="checkbox" ValidationGroup="VGEdit">
 </asp:CheckBoxList>

 <asp:Label ID="Label12" runat="server" Text="Select up to 3 Business Types" CssClass="label_black"></asp:Label>
 <asp:TextBox ID="txtCheckbox" runat="server" ValidationGroup="testGroup" style='display: none;'/>

<asp:RequiredFieldValidator ID="valCheckboxList" Display="Dynamic"
           ErrorMessage="At least one business type must be selected"
           runat="server" ControlToValidate="txtCheckbox"
           ValidationGroup="VGEdit" EnableClientScript="true" CssClass="ErrorLabel_10"
           SetFocusOnError="true"/>

Listing – 2 : jQuery Script for RequiredFieldValidator

  <script type="text/javascript">
        $(function() {
            function checkBoxClicked() {
                //Get the total of selected CheckBoxes
                var n1 = $("#<%= cblBusinessType.ClientID %> input:checked").length;
                //Set the value of the txtCheckbox control
                $("input:#<%= txtCheckbox.ClientID %>").val(n1 == 0 ? "" : n1);
            }
            //intercept any check box click event inside the #list Div
            $("#<%= cblBusinessType.ClientID %> :checkbox").click(checkBoxClicked);

        });
    </script>

Check for Maximum Selection Limit

We also often need to check that user can select only n items from the checkboxlist. so for that I have anothe jQuery script that help the developer to restrict the user from selection after he reach the max limit.

Listing – 3 : jQuery Script for Maximum Selection Limit

 <script type="text/javascript" language="javascript">
         //Count the Total Selection in CheckBoxList - BusinessType
         $('#<%= cblBusinessType.ClientID %>').find('input:checkbox').click(function()
         {
              var totCount=0;

              jQuery('#<%= cblBusinessType.ClientID %>').find("input:checkbox").each(function() {

              if (jQuery(this).attr("checked"))
              {
                totCount++;
              }

            });
            if(totCount > 3)
            {
                alert("Select up to 3 Business Types only...");
                return false;
            }

            return true;

         });
 </script>

Here in this function I have counted each selected checkbox by using jQuery selector each time user check/uncheck the checkbox. once the count goes beyond the limit flag the error message to user to remind that you have crossed the limit.

Hope this will Help
Jay Ganesh

Shout it kick it on DotNetKicks.com

Posted in JQuery | Tagged: , , | 4 Comments »

 
Follow

Get every new post delivered to your Inbox.

Join 124 other followers