providing suggestion of words in thesearch box from a list in the text File

Hi

So I have continued added more and more Ajax to the site. Now I have added Auto Suggest Box to the site. The search box on the left has been made into an auto suggest box. Although the numbers of words at present are not very high but with the word manager ready it should be a matter of time when I will have many words to the auto Suggest in the search box.

Adding Auto suggest box using Atlas (Microsoft ASP.NET Ajax extension) was very easy. You need a web service (returning the list of words), the autocompleteextender to show the panel and a text box. The webservice is required to return an array list.

The code to use the autocompleteextender is very simple

<Atlas:autocompleteextender id="AutoCompleteExtender1" runat="server">

Continued...

Caching a part of the page when most of the page is rendered dynamically

Hi

Most of the time it is not practical to cache the entire page, as and important section of the page is dynamically generated from the database. But in those pages there is much content. As in my site the name of the category and the number of post per month are fairly static (Until I add a post or category). Since Output Caching caches the HTML or the entire ASP.Net web page, it cannot be used for these scenarios. If I try and cache all the posts (VaryByParam) then it will be a huge amount of cache in the memory and might slow down the site further.

For these scenarios we can use Partial-Page Output Caching.

Continued...

Using the System.Media.SoundPlayer class to play sound
Hi

System.Media Namespace provides many classes to work with the Sound in the application. One of the important classes to play sound is SoundPlayer class. With the help of this class we can simply WAV Files.

The wave files can be loaded by using either the file path, The URL or a stream that contains the .wav file. We can also use an embedded resource that has the .Wav file.

Continued...

New features of the New web Project System

Hi

With visual Studio 2005 and Asp.Net 2.0 Microsoft brought out a new project Model (Web Project Modal). Here I am going to discus some of the features of the Web Project Modal.

One of the more important features of the web project is that there is no more requirement of the front-page server. With the new project modal we can open the local IIS Application and the virtual directory without FPSE. We can also open and edit the projects from the file system or even remotely over FTP. The FPSE is still supported but it is not required.

The new Visual Studio also comes with a built in WEB SERVER (CASINI). So this means that we can do the development even if there is no IIS installed in the machine. The studio also supports debugging application running within it while using the normal user account and not necessarily Administrator.

Continued...

Using Atlas Accordion Control to display multiple panel with one panel visible at a time

Hi

Accordion is a web control that is used to display multiple panel with one panel visible at a time. Its like have many collapsible panel where only one is visible at a time. The Accordion is a web control and has accordion pane. Each pane can have its header and content. This control also remembers its state during the post back. To fit the variety of layouts its support 3 auto size modes (None, Limit and full).

The control also support being data bound with its datasource and databind methods.

The code to use the Accordion looks like this.

Continued...

Using Atlas UpdatePanelAnimation Extender to get "watermark" behavior

Hi

UpdatePanelAnimation Extender is a simple and very good up gradation of the Update Progress. It allows declerative fashion and us to use the powerful animation framework in a very easy. We can use the Update panel Animation extender to play animation both while the update panel is updating and also when the update panel has finished updating. This can help us interact with the user while there is a call back in process and we can use the existing Animation framework to provide users with good interactivity while the call back is in process and also when the call back has completed.

The code to use the UpdatePanelAnimation Extender looks like this.

Continued...

Using Atlas TextBoxWatermark Extender to get "watermark" behavior

Hi

TextBoxWatermark is an "Atlas" extender that can be attached to an ASP.NET TextBox control to get "watermark" behavior. We can also add custom CSS and a message in the textbox when the textbox is empty. And the Watermarks go away once a user has typed in some text in the textbox. The textbox extender can we used efficiently when we want to show user some more information on what this textbox is for without cluttering up the rest of the page.

The code to use the TextBoxWatermark Extender looks like this.

Continued...

Using Atlas ModalPopupExtender for displaying Modal content to the users
Hi
Earlier there was no way to show a Modal pop-up to the user in ASP.NET. The Atlas’s ModalPopupExtender allows the display of content in a modal manner (A modal pop-up stops the user interaction with the rest of the page till the modal pop-up is there. The content of the modal pop-up can be any number of control and HTML with CSS applied to them.
When the modal pop-up is displayed the user can only interact with the modal pop-up content. When the interaction with the pop-up completes then only the user can interact with the rest of the page. Custom script and post back can take place when the user completes the interaction with the modal pop-up.

The code to use the ModalPopupExtender looks like

Continued...

Using Atlas FilteredTextBoxExtender for the convenience of users

Hi

Validation User input is very important in the Web. Although ASP.NET has a rich set of validation control we some time want to prevent a user from entering any invalid characters.

Lest say, we have a textbox control where the user needs to enter the number of products he will buy. We can always validate the value that he enters in the text box but the best thing would be if we do not allow him to enter any thing other that numeric value in the textbox.

We have a new extender in the ATLAS toolbox for such requirement (FilteredTextBoxExtender).

The code to use the FilteredTextBoxExtender looks like this.

Continued...

Using Atlas ConfirmButtonExtender to display confirm messagebox

Hi

One of the good things about using ATLAS (ASP.NET Ajax extender) is that it makes most of the JavaScript get done without using a single line of java script. The same is true if you want to display a message box to the user when he clicks on a button (lets say a delete or a update button). If the User clicks on the ok button then only the button functionality is performed normally otherwise the button does not perform its normal submit functionality.

The extender can be used with Normal Button, Link button or an image button. The code to use the ConfirmButtonExtender looks like this.

Continued...

Forms Authentication timeout and session time out are different and independent of each other
Hi

Here is something I came across that was very interesting. In asp.net we can set the time out for both Form Authentication and Session. These two times can be different.

Hence you can have Forms Authentication time-out is greater than the Session time-out.

[Note: there is a difference in Version 2.0 from V1.X that the value for cookie Expiree (Time-out) is set for both the persistent and non-persistent setting (previously it was only used for the non-persistent case). Previously, the persistent duration was just hard-coded to a really long time]

Although it’s a little bit hard for me to understand how you can time-out and persistent cookie and still say it’s persistent.

Continued...

Shrinking SQL Server Data File

Hi

From time to time we all need to clear up dev server, truncate the log-file and resize the bloated LDF file of the SQL Server.

How to do it?

Suppose the name of the database is Vikram

First we make the server truncate the log the next time it runs the checkpoint.
EXEC sp_dboption 'Vikram', 'trunc. log on chkpt.', 'TRUE'

Now force a check point for the database
CHECKPOINT

Continued...

A comprehensive look at the Master Page

Hi

One of the great additions of ASP.NET 2.0 is Master Page. Master page helps us build a consistent and maintainable UI through out the site.

So how does a Master Page works?

The master Page and the content page merge there content together to create a single aspx page when a request for page arrives, which is using master page. Lets create a simple master page.

Continued...

Some good images to be used in Update Panel
Hi

I found some cool Links which provide some useful images that can be used with the update Panel control. Check these out

http://mentalized.net/activity-indicators/
http://www.napyfab.com/ajax-indicators/
http://www.ajaxload.info/

Hope this helps
Thanks
Vikram

play animations both while an UpdatePanel is updating and after it has finished updating

Hi

If you want to show the users some animation with the Update panel is calling back, the new UpdatePanelAnimation control is what you need. To make this work we will have to use the UpdatePanelAnimationExtender. The full code to make the animation is given below.

Continued...

Using Atlas to add animation to your site

HI

A new toolkit of ATLAS has released. The Latest thing in Atlas’s great collection of control is Animation. So that’s what I tried my hand upon first-up. You can use the Animation control to add animation to your website. I have added a little animation to the site and will be adding more. There are two new buttons in the left bar “Animate the Left Bar” and “Animate the Main Blog”. When you click the button you will see animation on the site on the left button and the main blog respectively. I should thanks (Farghana again) for the color for animation. This is my first look at the Animation. I will be adding more animation to the site.

Continued...

How to use Generics in DOT NET 2.0
Hi

In Dot Net 1.X developers had to use System.Collections non-Generic collections for their Objects and hence had no type checking. So the developer would have to do type casting while retrieving the objects. One of the main new features of DOT NET (Generics) has made life easier for the developers. Another important reason for using Generics against Non Generics in performance. Reading objects from and Array List will have better performance since we will not have to type cast the Object. Generics also gives us compile time Type safety.

So how does Generics change our code?

In Dot Net 1.x Array list was one of the most common to store objects since it can save any collection regardless of their type. We used to type cast the objects when we used to retrieve them.

List<T> can be used as a good alternative to Array List. The main difference is that List<T> is type specific.

Continued...

Do not forget to set The Application Name property when working with the providers of the ASP.Net
Hi

Whenever you use the Membership and role API of the ASP.NET 2.0 remember to configure the Application Name. If you do not give an Application name and restart your application all the data related to your previous Application will be useless.

When the application Name attribute is not configured, ASP.NET uses the application virtual root path within the web-server to automatically create application Name. This Application name is used when adding data to an ASP.NET Application Service database. Now when you restart the Application a new Application name is created and makes all the data related to the previous Application name waste for you.

Continued...

Site Map added to the site using a DataList inside another DataList

Hi

Now I have also added a Sitemap to the Site. The sitemap has the entire link in the Site.

It also shows the list of Posts by category and by month. To show all the name of the categories and the posts in that category I used a Data List inside a Data list. This creates a tree view like structure that shows the entire category and inside all the category links to all the posts for that category.

Thanks
Vikram


How to use Master page with more than one content template and update only those content Template which are needed to be changed

Hi

Of late some people have asked me about a particular feature of the master page, which is very helpful in the real life scenario. The property to make the header and footer of the page also dynamic using the Master page. This is very important in the real life scenario.  There are many a time when we do not want to show the header or the footer in one or two of the page. Or in place of the current Header we want to show some different header.  No one wants to have the headache of having another master page for these pages.

So how to achieve this. We can have more than one content template in the master page. Lets say we have three content templates in the master page.

Continued...

Rewriting the URL of the Site using HTTP Modules

Hi

So after spending some time with the site one thing I realized that the next thing that needs to be done to the site was URL Rewriting. Now you can see the site working with URL Rewriting. I did not like having meaningless URL's for visitors (i.e. post.aspx?postid=3), and hence went for URL Rewriting.  I had worked on URL Rewriting on asp.net 1.1 so I decided to work on that library only. I use HTTP Modules for URL Rewriting (I know we have other option like IIS, HTTP Handler etc). The main reason for the decision was that I already had the library with me and it took only a couple of hours to complete the work (including creation of rules).

Continued...

How to use a control to send its HTML as and Email

Hi,

Many a time we want to send Email, which resembles the output of a web control. When trying to send an Order confirmation Email where you are sending the description of all the products bought by the user. [The number of product can be anything]. At these occasions it would be great to be able to send the output of a web control.

For this article I am assuming that the SMPT server is configured. (To send Emails using your Gmail Account check this post) We can capture the output of most of the control using their Render Control method. After that you can send the output of the control through a mail.
Here is the code for

Continued...

How to put focus on a control through server side code in ASP.NET

Hi

Many a time you need to set the focus of the form to a particular control. There is no way to do this with server-Side scripting. This needs to be done through Client-Side Scripting. The following JavaScript snippet can be added to the bottom of the HTML view of your page:

<script language="javascript">
      document.getElementById("TextBox1").focus();
</script>

Continued...

ASP.NET Application object events and how can they be used

Hi

ASP.NET Application Object has large number of event where each event can be used for a specific functional purpose. ASP.NET pipeline is a step-by-step process through which various parts of the request are processed in a structured manner. These events can be categorized in two types.

  • Request Related Events.
  • Response related events

[Note: There are many Request related events that only occur under certain condition. (Like application start event, session start event). These have been discussed later].

The event, which occurs when a new request is received, is listed in their order of occurrence respectively.

Continued...

So another Langauge gets released
Hi
Great news today is the fact that a Iron Python Version 1.0 is shipping today.
You can get the download here
http://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=IronPython&ReleaseId=423

Also shipped is a ton of code with it so that people can see just how it is done as well as run their favorite Python code at CLR speeds.

Enjoy
Thanks
Vikram

AppendDataBound Items lets you add static data to dynamically populated list
Hi

There are quite a few features in ASP.NET 2.0. One of new healthy features in list controls (CheckBoxList, ListBox, DropdownList etc...) is the new property "AppendDataBoundItems" You can bind the list controls to some data source and also add some static data. If the "AppendDataBoundItems" property is set to true then you will get all the date (static data and data populated by data source) in the list. This is very handy if you want to add a "Select One" item in the Dropdownlist and listbox.

Continued...

Added another theme to the site using ASP.NET 2.0 Themes
Hi,

So a new week started and with it I added a new theme, which I find really cool. And once again I have to thank Farghana, (despite the faces she makes at me and hitting me with pen, paper or whatever is at hand, ok I forgive you farghana, for you know not what you are doing! ) for such a beautiful creation. Named it Green Atlas.

Suggestions for any other name are welcome!

Thanks
Vikram

AppendDataBound Items lets you add static data to dynamically populated list

Hi

There are quite a few features in ASP.NET 2.0. One of new healthy features in list controls (CheckBoxList, ListBox, DropdownList etc...) is the new property "AppendDataBoundItems" You can bind the list controls to some data source and also add some static data. If the "AppendDataBoundItems" property is set to true then you will get all the date (static data and data populated by data source) in the list. This is very handy if you want to add a "Select One" item in the Dropdownlist and listbox.

Continued...

Difference between the ReadOnly and Enabled property of TextBox.

Hi

One of the things that confused me most in the textbox was the two properties Enabled and ReadOnly. The other standard input Web controls - the Checkbox, Radio Button, Dropdown List, RadioButton List, Checkbox List, ListBox, etc. - lack the ReadOnly property and offer only Enabled.

Continued...

How to set the rich textbox to the last line when the text is changed

Recently I was working with Windows form and wanted the scroll of the rich textbox to be on the last line when there was some text changed. I am very new to windows form (having worked mainly in web forms [Asp.Net]).

Then I saw this property of the textbox called ScrollToCaret. So what I did was made the selection start at the end of the textbox and scroll the caret there.

this.txtMessages.SelectionLength = 0;
this.txtMessages.SelectionStart = this.txtMessages.Text.Length;
this.txtMessages.ScrollToCaret();

Continued...

How to make Membership, Profile and other built in API to use SQL Server 2000 instead of SQL Express.
Hi

ASP.NET 2.0 comes with some great API’s like Membership, Roles API, Profile API, health monitoring API. Etc. These API use the default providers to store data. Like the Membership API uses the SQL Express database by default to store the data. But many a time you want to use other database. I wanted to store the Membership and profile data in the SQL Server 2000 database.

With ASP.NET 2.0 Provider model this can be done in a few steps.

First we create a new database and obtain its connection string.

Continued...
 
Copyright © 2006 - 2010 Vikram Lakhotia