Sunday 11 October, 2009

ASP.Net AJAX Control Toolkit’s New Release, AsyncFileUpload Control


Ajax Control Toolkit is not new for every .NET developer. A new version of the AJAX Control Toolkit is now available for download from the CodePlex website. This new version of the AJAX Control Toolkit contains two new controls:
  1. SeaDragon Java Script Code (SJC) - The SJC control allows SeaDragon scripts to be used to display an image, and to zoom in and out of that image using mouse button keys without resizing the window. I saw the demo and it's a really cool control.
  2. AsyncFileUpload - Finally, we have a control which uploads file asynchronously. This new control enables you to perform file uploads without doing a postback. The control displays a throbber image during upload and raises client and server events when the upload is complete. Check the live demo here.
Note: This control will only work with .NET 3.5 or higher version.

PingBack From :Code Project

Difference between obj.ToString() vs Convert.ToString(obj) vs (string)obj vs obj as string

obj.ToString()


.ToString() can be called from any object. It returns a string that represents the current Object. ToString() is a method of object, and it will always work on a non-null reference. For example:

object str = "test string";
string newTestString = str.ToString();

str.ToString() will return "test string" as string .But

object str = null;
string newTestString = str.ToString();


Will throw the exception:“Object reference not set to an instance of an object.”
The above exception came because str is null we can not perform any operation on any object that has null reference.

Convert.ToString(obj) :

Convert.ToString(obj) means we are calling a method and passing obj as argument.Internally it will call ToString(object value) method and then ToString(object value, IFormatProvider provider) method is called.

(string)obj :
First it should be clear that it is a cast operation, not a function (or method) call. We should use this if we are sure the object we are passing is of type string or it has an implicit or explicit operator that can convert the object to a string. This will return null if the object itself is null . See examples.

object str = "test string";
string newTestString = (string)str;

(string)str will return "test string" as string.But you cant do tht for Int.See below example:

object i = 2;
string str = (string)i;

The above code will throw this error:
Unable to cast object of type 'System.Int32' to type 'System.String'.Cannot cast expression of type int to string
Int doesn't have an explicit operator to string.When casting a number to a string, there is a "loss" in data. A string cannot perform mathematical operations, and it can't do number related things.

obj as string :
It is safe cast operation. It is similar like (string)obj but instead of throwing an exception it will return null if cast operation fails. For example:

object i = 2;
string str = i as string;

str will return null.

Code Translation for .Net c# < = > VB.Net

This service will translate the code for you, just start typing the code or upload a file to convert it.

For now it only supports from VB.NET to C# and from C# to VB.NET.

VB.NET to C# and from C# to VB.NET Click Here

To use it you can either:
Start typing your code.
Copy and Paste the code in the Code Text Box.
Translate an entire file using the file upload.

Disclaimer:
No copy is done whatsoever of the code that you either type, or upload for translation. Everything is processed in the server in memory and returned immediately to the browser

Saturday 10 October, 2009

How to control maxlength of multiline textbox in aspnet

This is known issue in ASP.NET Standard Text box control when set its TextMode="MultiLine" the MaxLength property does not work.

There is a workaround to accomplish this using two ways :
1. RegularExpressionValidator : Following is the markup that will restrict the text box to maximum of 300 characters.
<asp:TextBox ID="txtComments" runat="server" TextMode="MultiLine" Height="100px"
Width="320"></asp:TextBox> 
<asp:RegularExpressionValidator
ID="regComments" runat="server" ControlToValidate="txtComments"
ValidationExpression="^[\s\S]{0,500}$" ErrorMessage="Maximum 300 characters are allowed in comments box." Text="Maximum 300 characters are allowed in comments
box." > 
</asp:RegularExpressionValidator>

2.By JavaScript :
The MaxLength property of textbox control works fine if Multiline mode is not set, but if TextMode='Multiline' is set in aspx page then this property is of no use and user can input any number of characters inspite of setting maxlength.
Single line textboxes render as an HTML input tag - which supports a max
length.

The Multiline Textbox, renders as an HTML TextArea which doesn't support a
length property.

So, one workaround is to roll your own by calling a JavaScript function that
checks the length of the text entered. The function gets called on every
keypress and denies further data entry when the max length is reached. Of
course the JavaScript function needs to ignore some keys. This one should
work.

This example requires just very basic knowledge of java script so don’t be scared I promise this will be one of the easiest java scripts that can solve a complex problem.

Add the following to your Multiline box in aspx page:
<asp:TextBox Rows="5" Columns="80" ID="txtCommentsForSearch" MaxLength='500' onkeyDown="checkTextAreaMaxLength(this,event,'500');"  TextMode="multiLine" runat="server"> </asp:TextBox>
        

*txtCommentsForSearch-This is asp.net control that is having multiline property set

I have used MaxLength='500', same property you have to use in underlying javascript file also. I have also passed this length to the calling javascript method, so that in case the MaxLength is not accessible then can be picked from parameters of javascript method.

Add the following to your javascript file:
function checkTextAreaMaxLength(textBox,e, length)
{
    
        var mLen = textBox["MaxLength"];
        if(null==mLen)
            mLen=length;
        
        var maxLength = parseInt(mLen);
        if(!checkSpecialKeys(e))
        {
         if(textBox.value.length > maxLength-1)
         {
            if(window.event)//IE
              e.returnValue = false;
            else//Firefox
                e.preventDefault();
         }
    }   
}

function checkSpecialKeys(e)
{
    if(e.keyCode !=8 && e.keyCode!=46 && e.keyCode!=37 && e.keyCode!=38 && e.keyCode!=39 && e.keyCode!=40)
        return false;
    else
        return true;
} 

Sunday 27 September, 2009

How to Generate Sequence Diagram online


How to Generate Sequence Diagram online
Don't wast your time to create sequence diagram using visio or some
other tools.
Here I found very useful site that generates sequence diagram as per
your requirement.
You have to just type very smple script that should descripe the call
from one class to
another and On click of "Draw" button you can get your secquence diagram
in the form of picture or pdf.
Don't worry about script learning and script notation, it's
very,following site will give you all help and example
pink back from :
http://www.websequencediagrams.com/

Formatting numeric data types in .NET

Formatting for decimal places.
Formatting numbers.
Formatting numbers using # symbol.
Formatting for thousand separator.
Formatting for positive and negative numbers.
Multiplying a number by 100.
Appending currency symbol to a number.
Displaying numbers in exponential form.


Thanks to Sandeep for Sharing Such formatters......

Methods in Global.asax


It’s very important to understand the methods in global.asax so that we as programmers can handle some application level events very efficiently. I said application level events and reason for using application word is that global.asax is an application level file and methods in it are used to handle application level events and these methods are not at all specific to any aspx page. Some of the common methods in the order in which they are executed are listed below
  • Application_Start
  • Application_BeginRequest
  • Application_AuthenticateRequest
  • Session_Start
  • Application_EndRequest
  • Session_End
  • Application_End
  • Application_Error
PingBack from Methods in Global.asax

Configuring Machine Key in ASP.NET 3.5 to tamper proof viewState

Security is a major concern when it comes to online transactions like shopping. Today we will learn how to tamper proof your ASP.NET application using element in web.config file. How to protect your sensitive ViewState data and Forms authentication ticket.

By default, ViewState in ASP.NET is encoded and not encrypted as you might feel. ViewState is transmitted to server as a Base64 string and can be easily decoded.Take a look at this if you are interested in decoding stuff and read more about Base64 here.

Encrypting and protecting ViewState: For a tamper proof ViewState a hashed message authentication code (HMAC) is generated from ViewState data which is then compared on subsequent requests. We can make use of element and can encrypt our ViewState using desired encryption mechanisms. Eg, SHA1 , MD5, AES and 3DES. Here is how a element looks but before that we need to set enableViewStateMac=True in our asp.net page as shown below code segment.
<%@ Page  EnableViewStateMac="true" ViewStateEncryptionMode="Auto"  Language="C#" AutoEventWireup="true" CodeBehind="login.aspx.cs" Inherits="Using_SQL_Membership.login" %>

Or you can set it in web.config file as shown below.


enableViewState=True enables hashing of viewstate while you viewStateEncryptionMode takes 3 values. Auto, Always and Never. With viewStateEncryptionMode set to Auto, the page is only encrypted if a control has specifically asked for it by calling the Page.RegisterRequiresViewStateEncryption() method to request encryption. If it set to Always, this forces encryption even if a control does not request it. For performance reasons do not encrypt viewState unless and until it has sensitive data.



1. validationKey: This specifies the key that the HMAC algorithm uses to make ViewState tamper proof.

2.decryptionKey: specifies the key used to encrypt or decrypt data. Also, ASP.NET uses the key only if validation attribute is set to AES or 3DES.

3.validation: specifies the hashing algorithm used to generate HMACs to make ViewState encrypted.

In general, you should choose SHA1 over MD5 for tamper-proofing because this produces a larger hash than MD5 and is considered cryptographically stronger.

Encrypting and protecting Forms Authentication:

To ensure that forms authentication tickets are encrypted and protected against tampering, set the protection attribute of the element to All, as shown


Along with this make same settings to machineKey as shown above.

If you deploy your application in a Web farm, you must ensure that the configuration files on each server share the same value for validationKey and decryptionKey, which are used for hashing and decryption respectively. This is required because you cannot guarantee which server will handle successive requests.

Viewing ASP.NET viewstate with ViewState Decoder
Do you ever wonder what may be inside that asp.net viewstate? As a tester don't you think you should? It's a good thing to wonder about if you care about security. It's possible that the viewstate could contain sensitive user information that could be compromised in a man in the middle attack. For example: A user can input a credit card number into a textbox which would be passed to the next page via the viewstate. Not good... The viewstate is not encrypted by default its just simple Base64 encoding which can easily decoded with cool little tools like ViewState Decoder made by Fritz Onion.

ASP.NET View State


What is a view state?
View state in simple terms can be defined as a way to maintain the state of an aspx page during postbacks. And this is the no 1 one liner answer I get from candidates during interviews. Viewstate is a technique which helps in retaining the values of the controls placed in a page during postback/roundtrip. With this blog, again, my aim is the same, to spread more light on what is view state all about.


What do you mean by state of an aspx page?
The state of an aspx page means the values of the controls in an aspx page. By default the view state is maintained for all the controls which are placed in an aspx page. The state of a control can be the text entered in a text box, the checked status of a radio button or check box, the content and selected item in a drop down control etc.



Where is view state stored?
View state is stored in the client in the form of a hidden control called “__VIEWSTATE”. Here by client I mean the rendered aspx pages in the browser. If view state property is set to true then ASP.NET automatically adds a hidden field/control by the name “__VIEWSTATE” and stores the information related to the state of the page in an encrypted format.


What is the encoding used in view state?
View state is stored in base64 format. The base64 format can generate huge amount of data on conversion and this is the reason we are adviced to use view state judiciously.



Which class handles view state?
StateBag class handles the view state and it implements a Dictionary to keep track of the changes in a form. The developer can add or remove items from this dictionary as you would from any dictionary object. You can access this class through the Control.ViewState property.


Can view state be stored in multiple hidden fields?
Yes, view state can be stored in multiple hidden fields. This can be achieved by setting the page’ “MaxPageStateFieldLength” property. If the property is set to a positive value then the view state is broken and sent to the client in multiple hidden field and each field’ size will be less than the value spedified in “MaxPageStateFieldLength”.



How to disable view state?
View state can be disabled in the following ways.



1. In machine.config – you can disable view state for all the application hosted in the server by modifying the following tag in machine.config as shown below.

2. Application/website level - if you want to disable view state for all the pages in your application then you can do that in web.config file as shown below.


3. Page level – you can use this option to switch off the view state for all the controls in a web page by setting the “EnableViewState” page attribute

4. Control level - you can switch off a control’ view state by setting the EnableViewState property of the control to false from property window or as shown below.


Hope the above details give a clearer picture on what view state is. There is more to view state than what is written here.


Microsoft Releases Charting Control as VS2008 Add-on

As you may (or may not) know, a while back Microsoft purchased some charting functionality from Dundas, to be included as part of Reporting Services for SQL Server 2008. Well, now they have packaged up this functionality as a control for Visual Studio 2008! This is a fantastic add-on, as we now have the power, flexibility, and visual excellence of the old Dundas chart control as a free Visual Studio 2008 add-on!


Scott Guthrie has an excellent blog post discussing it, which can be found here.


Scott specifcially talks about ASP.NET, and a few of the commenters on his blog ask the obvious question: Can this be used for Winforms apps as well? I went ahead and installed the add-on, and the new Chart control can indeed be dropped into Winforms apps as well as ASP.NET!


Lastly, I got curious as to whether or not this control could be used from Visual Studio 2005. It doesn’t show up in the toolbox automatically, but it can be added and does indeed work in VS2005!




In addition to the above samples, you can download the Microsoft Chart Control Documentation





Simple tips: Set Focus to TextBox in GridView (edit mode)


If you use TemplateField like


            
                
             
            
                
             
        


 You could do it in RowEditing, for example:

protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
        {
            //Normal turning to edit
            GridView1.EditIndex = e.NewEditIndex; 
            BindGrid();

            //Set the focus to control on the edited row
            GridView1.Rows[e.NewEditIndex].FindControl("txtEdit").Focus();
        }

I'm binding the grid manually, therefore there is setting the index and calling databinding functions. However, with BoundField (I have CommandField as left most column) it could be something like:

GridView1.Rows[e.NewEditIndex].Cells[1].Controls[0].Focus();

where Cells[index] is the one you should be modifying based on which column it is in question (still doing in RowEditing)
In case you use data-source controls, it might be feasible to do it in RowDataBound:

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowState == DataControlRowState.Edit)
            {
                //Set the focus to control on the edited row
                e.Row.Cells[1].Controls[0].Focus(); 
                //Or to a specific control in TemplateField
               // e.Row.FindControl("txtEdit").Focus(); 
            }
        } 

Windows Media Player and Music Status In Gtalk


A post From Google Talk groups (Google) , i thot this wil be useful for most of the gtalk users who are searching for this issue for a long time ….
Hi everyone,
I just wanted to add a little something about an
issue that sometimes comes up when users are trying to share their
music status in Google Talk using Windows Media Player.
When Windows Media Player or your Windows desktop crashes, Windows
Media Player is designed to disable all plug-ins (including the Google
Talk music status plug-in). If this happens, the current music track
you’re playing on Windows Media Player won’t show up as your Google
Talk’s status message.
I know many of you have found the solution to this problem, but for
those who haven’t found this fix before, all you need to do is
re-enable the Google Talk plug-in. Just follow these steps:


1. Open Windows Media Player.
2. From the View menu, select ‘Plug-ins’ > ‘Options…’
3. From the Category section of the Plug-ins tab, select ‘Background.’
4. Select the ‘Google Talk Music Plugin’ checkbox.
5. Click ‘OK.’
You’ll have to close and restart Windows Media Player for your change
to take effect. 

But sometimes the problem started when I tried to used in WMP 11 on Windows Vista Home Premium ...
this is for vista! 
INSTALLING GTALK AND MEDIA PLAYER DISPLAYING THE TRACKS.
all you have to do is right click your gtalk installer. before that close both your media player and gtalk, it doesnt matter if you installing the same version. instead of clicking on install, you RUN AS ADMINISTRATOR. wait a little, open you gtalk, choose to show current track, run your windows media player and play a track, now the media file`s name should be displayed.
cheers.

Happy music status sharing!

Thursday 10 September, 2009

Visual Studio Add-Ins Every Developer Should Download Now

Visual Studio provides a rich extensibility model that developers at Microsoft and in the community have taken advantage of to provide a host of quality add-ins. Some add-ins contribute significant how-did-I-live-without-this functionality, while others just help you automate that small redundant task you constantly find yourself performing.

TESTDRIVEN.NET :
Test-driven development is the practice of writing unit tests before you write code, and then writing the code to make those tests pas

GHOSTDOC :
XML comments are invaluable tools when documenting your application. Using XML comments, you can mark up your code and then, using a tool like nDoc, you can generate help files or MSDN-like Web documentation based on those comments. The only problem with XML documentation is the time it takes to write it you often end up writing similar statements over and over again

SMART PASTER:
The Smart Paster add-in helps to limit some of this by providing a number of commands on the right-click menu that let you paste a string from the clipboard into Visual Studio using a certain format. After installing Smart Paster, you will see the new paste options available on the right-click menu.

CODEKEEP:
CodeKeep is a Web application that provides a place for people to create and share snippets of code in any language. The true usefulness of CodeKeep is its Visual Studio add-in, which allows you to search quickly through the CodeKeep database, as well as submit your own snippets.

PINVOKE.NEThttp://www.pinvoke.net/ :
PInvoke.NET is a wiki that can be used to document the correct P/Invoke signatures to be used when calling unmanaged Win32 APIs. A wiki is a collaborative Web site that anyone can edit, which means there are thousands of signatures, examples, and notes about using P/Invoke.

VSWINDOWMANAGER POWERTOY :
VSWindowManager will automatically switch between the design and coding layouts depending on whether you are currently viewing a designer or a code file. You can also use the commands on the Apply Window Layout menu to choose from your currently saved layouts. When you select one of the layouts you have saved, VSWindowManager will automatically hide, show, and rearrange windows so they are in the exact same layout as before.

WSCONTRACTFIRST:
WSContractFirst makes it easier to write your WSDL file, and will generate client-side and server-side code for you, based on that WSDL file.

VSMOUSEBINDINGS :
VSMouseBindings makes extensive use of the command pattern. You can bind mouse buttoms to various commands, such as open a new file, copy the selected text to the clipboard, or just about anything else you can do in Visual Studio.

COPYSOURCEASHTML:
After installing the CopySourceAsHTML add-in, simply select the code you want to copy and then select the Copy Source as HTML command from the right-click menu .

CACHE VISUALIZER :
ASP.NET Cache represents a collection of objects that are being stored for later use. Each object has some settings wrapped around it, such as how long it will be cached for or any cache dependencies. There is no easy way while debugging to get an idea of what is in the cache, how long it will be there, or what it is watching. Brett Johnson saw that gap and wrote Cache Visualizer to examine the ASP.NET cache.

WRAPPING IT UP:

While this article has been dedicated to freely available add-ins, there are also a host of add-ins that can be purchased for a reasonable price. I encourage you to check out these other options, as in some cases they can add some tremendous functionality to the IDE. This article has been a quick tour of some of the best freely available add-ins for Visual Studio. Each of these add-ins may only do a small thing, but together they help to increase your productivity and enable you to write better code.

Wednesday 9 September, 2009

How to add syntax highlighting to Blogger with Alex Gorbatchev's open-source SyntaxHighlighter.

How to display code (nicely) in Blogger posts
I’ve long been envious of all those blogs that show code, nicely formatted and even with line numbers! I finally found out how it’s done.

How to add syntax highlighting to Blogger with Alex Gorbatchev's open-source SyntaxHighlighter.
1.Log into your blogspot account, select the "Layout" tab, and then click "Edit HTML."
2.Click "Download Full Template" to make a backup of your current template.
3.Make a copy of your template, open it in an editor, and find the </head> closing tag. Before that tag, add the following:

<link href='http://alexgorbatchev.com/pub/sh/current/styles/shCore.css' rel='stylesheet' type='text/css'/>
<link href='http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css' rel='stylesheet' type='text/css'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js' type='text/javascript'/>
<!-- add brushes here -->
<script type='text/javascript'>
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.all();
</script>


4.After the comment that says "add brushes here," add the languages you plan to use.
For example, I'm using brushes for Javascript, CSharp, SQL, XML/HTML, and C++:

<!-- add brushes here -->
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCSharp.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushSql.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCpp.js' type='text/javascript'/>


5.See the full list of supported syntaxes.

6.Save your modified template, and upload it to Blogger (again, under Layout > Edit HTML).

You should now be able to add syntax highlighting to your blog. Wrap your code in a <pre> tag and specify the brush to use in the class attribute. For example, to highlight a block of SQL:


SELECT *
FROM users
WHERE user_id = 1212;


6.If Blogger produces an Error message, saying something like a tag isn't allowed, simply click the checkbox to ignore, and hit Publish Post.

7.All thanks goes to Alex Gorbatchev for creating Syntax Highlighter in the first place. If you want to speed up things, you might want to host the Syntax Highlighter files on your own webspace (such as on a free webhost; just google).

8.If you don't care about fancily presented code and just want the job done, visit the HTML Entities Encoder and simply copy-paste...:)

HAPPY CODING :)




Sunday 2 August, 2009

Ajax Autocomplete textbox add progress Image using javascript



This article demonstrates in a step by step fashion how to use the AjaxControl ToolKit’s AutoCompleteExtender control with an animated gif progress indicator while the target dropdown of the AutoCompleteExtender is waiting to be loaded.



This approach works if you are using newer versions of AjaxControlToolkit.dll (Version 1.0.20229.20821 or later)

For this write the below mentioned javascript in head section of html markup of the aspx page :

<script type="text/javascript">
 function ShowImage() 
{  document.getElementById('txtAutoComplete').style.backgroundImage = 'url(images/loader.gif)';
   document.getElementById('txtAutoComplete').style.backgroundRepeat= 'no-repeat'; 
   document.getElementById('txtAutoComplete').style.backgroundPosition = 'right'; 
}
 function HideImage()
 {
   document.getElementById('txtAutoComplete').style.backgroundImage  = 'none';
 }
  script>

For this write the above mentioned javascript in head section of html markup of page.
Now in source of autocomplete extender add onclientpopulating="ShowImage" andonclientpopulated="HideImage"

<ajaxToolkit:AutoCompleteExtender
 runat="server"
 ID="AutoComplete1"
 BehaviorID="autoComplete"
 TargetControlID="txtAutoComplete"
 ServicePath="AutoComplete.asmx"
 ServiceMethod="GetCompletionList"
 MinimumPrefixLength="1"
 CompletionInterval="10"
 EnableCaching="true" 
 CompletionSetCount="12"
 CompletionListCssClass="autocomplete_completionListElement"
 CompletionListItemCssClass="autocomplete_listItem"
 CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem"
 onclientpopulating="ShowImage"
 onclientpopulated="HideImage"
ajaxToolkit:AutoCompleteExtender>

Happy Coding......

Saturday 18 July, 2009

Source Code Formatter For Blogger , Blogspot , Blog, Blogging, Wordpress & Website

Source Code Beautifier And Formatter For Blogger and Websites, Format Source Code , Format Source code for blog or blogging & website, Online line source code formatter tool, blogger code format tool, Format source code for blogspot,Insert formatted source code

About Code Formatter.

- This source code formatter allow to format code like JavaScript, HTML, CSS, C#, PHP, ASP.net, VB.Net, Visual Basic, DOT.net, ASP & many other languages.

- This does not add unnecessary tags into formatted code, This use only two tag HTML tags & only once with formatted source code.

- This is pure javascript Application so dont worry anyone save your code.

- In the first release we have build it mainly for blogger, wordpress, blog .

- This is compatible with table less layout.

- In the next release we'll make it colorful code formatter tool for your blogger & website.

- Alternative backgrounds used in this tool.


Source Code Formatter..



Friday 17 July, 2009

ASP.NET Website vs Web Application project

Introduction
This post explains about two project types in Visual studio ie Website and Web Application that we use to build the ASP.NET Applications and the fundamental differences between the two project types..
Background
Website project type was introduced in the VS 2005 and Web Application model introduced in VS 2003. Website project type is based on folder structure and does not require a project file. Later in VS 2005 sp1 project file was introduced for the VS 2005 website project type.
Now in VS 2008 we can create both project types.

1.Fundamentally the behavior of the application types is same but website project type is folder based and WebApp is project type like normal project types in VS studio. In WebApplication project type project file defines the structure of the project.
2.WebSite project type contains the folders and anything that you put in the folder are dynamically compiled and be part in the website. More about ASP.NET Website Dynamic compilation here.
3.WebApplication project type contains the designer for the ASPX page and you can find the bin folder which contains the compiled assembly. So First difference can be summarized like ASP.NET website project type is dynamic and WebApp is more like structured. When you add a class file to the website project it will prompt you that it will place the file in App_code folder under root.
4. WebApp project type is restricted to one language where as Website you can add different language files to the App_Code folder which compiles the files dynamically.
5. Referring a user control in WebApp is straight forward.You can define the properties and can be accessed in class files like any other objects where as in website it is not.
6.We can put multiple language files in the Website but those files needs to be in same folder. If you change the location of the file then you need to mention in the Web.Config file as follows.. In compilation process you will have the finer degree of control in WebApp and it is not in Website because everything is dynamically compiled.
7.When you deploy the WebApps you can just copy the Compiled Assembly and Visual elements to the IIS folder where as in Website you need to copy everything to the IIS to work.
8.You can see the following dialogue box when you publish the files in Website If you select the precompiled option then you will find the precompiled folder in the published location there you find the multiple assemblies for each folder in the website.
9. If you use WebApplication project you can not access Profie at design time a workaround solution can be found here.
10. The following link helps you to choose which project type you have to user for the developing web applications.

New version of the ASP.NET AJAX Control toolkit

Latest version of AJAX Control Toolkit V 3.0 includes :


HTMLEditor: The HTMLEditor control allows you to easily create and edit HTML content. You can edit in design mode, as a rich text editor, or in source view to edit the HTML markup directly. HTMLEditor demonstration.


ComboBox: The ComboBox control provides a DropDownList of items, combined with TextBox. Different modes determine the interplay between the text entry and the list of items. ComboBox demonstration.


ColorPicker: The ColorPicker Control Extender can be attached to any ASP.NET TextBox control. It provides client-side color-picking functionality with UI in a popup control. ColorPicker demonstration.

Be sure to also check out the new videos dedicated for these controls and their new tutorials.
There’s also now a new tutorial available on Creating a Custom AJAX Control Toolkit Control Extender.

Many thanks to Alexander Turlov for building this.
Download AJAX Control Toolkit V3.0 to explore more controls

Sunday 5 July, 2009

Find Age from given DateOfBirth using C#

Find Age from given DateOfBirth using C# :

public string FindAge(DateTime dob, DateTime currentDate)

{
int years = currentDate.Year - dob.Year;
int months = 0;
int days = 0;
if(currentDate <>{
--years;
}
dob = dob.AddYears(years);
if (dob.Year == currentDate.Year)
{
months = currentDate.Month - dob.Month;
}
else
{
months = (12 - dob.Month) + currentDate.Month;
}
if(currentDate <>{
--months;
}
dob = dob.AddMonths(months);
days = (currentDate - dob).Days;
return years + " years " + months + " months " + days + " days";
}

Copy the above code in your class...and call the method..enjoy... ;)

Html Fieldset Rounded Corners - Internet Explorer (IE) and Firefox

Html Fieldset Rounded Corners - Internet Explorer (IE) and Firefox

I don't usually prefer anything about Internet Explorer. However, IE's default presentation for the Html fieldset tag just looks nicer. Firefox, on the otherhand, defaults to an ugly square box presentation. So, to try to get Firefox to look more like IE (something I never thought that I would say) ...

  1. fieldset {
  2. -moz-border-radius-bottomleft:7px;
  3. -moz-border-radius-bottomright:7px;
  4. -moz-border-radius-topleft:5px;
  5. -moz-border-radius-topright:7px;
  6. border-radius: 3px;
  7. }

Saturday 30 May, 2009

Getting started with jQuery

Key Features of jQuery

  • Support for Browser independence: jQuery is supported by most of the modern day browsers.
  • Support for a simplified Event Handling model: jQuery provides support for an excellent, easy to use normalized event handling model with much reduced code. The jQuery Event Handling model is consistent across all browsers. The even object is a cross browser normalized one and one event object is always passed as a parameter to an event handler.
  • Support for Seamless extensibility: jQuery provides support for extensibility through an easy to use plug-in API that enables extending the jQuery core library seamlessly.

Pre-requisites

To get started with jQuery you should have the following installed in your system:

  • Visual Studio 2008
  • Visual Studio 2008 SP1
  • jQuery Library
  • Visual Studio 2008 jQuery Plug-in

Downloading jQuery

You can download the jQuery library from this link: http://jquery.com/

As of this writing, the current version of jQuery is 1.3.2

Getting started with jQuery

In this section, we will explore how we can get started with jQuery in ASP.NET in a step-by-step manner.

Note: To get a feel of jQuery intellisense in Visual Studio 2008, you should install the HotFix: KB958502 that comes free from Microsoft. You should also download the jQuery Intellisense file and place it side by side along with the jQuery library in your Visual Studio solution, i.e., place it in the same path.

To get started with your first sample application in ASP.NET that uses jQuery, follow these steps:

1. Open Visual Studio and click on File-> New->Project.

2. Select .NET Framework 3.5 as the version and the ASP.NET Web Application template from the list of templates displayed.

3. Specify a name for the project and click OK to save.

4. Create a new folder in the solution explorer and name it as Scripts.

5. Right-click on this folder and select Add Existing Item.

6. Now, browse to the path where you have downloaded the jQuery library and the jQuery intellisense documentation.

7. Select the two files and click on Add to add the files in the Scripts folder.

8. Next, drag and drop the jquery-1.2.6.js file from the Solution Explorer on to the Head section of the Default.aspx file to create a reference as shown below:

1"server"
2    Getting Started 
3    "../Scripts/jquery-1.2.6.js" type="text/javascript"
4 

9. Now add the following script to your web page:

1"text/javascript"
2        $(document).ready(function()  
3        { 
4            alert("Using jQuery in ASP.NET"); 
5        }); 
6

The Complete Example

Here is the complete code for your reference:

1<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="_Default" %> 
2> 
3<html xmlns="http://www.w3.org/1999/xhtml" > 
4<head runat="server"
5    <script src="Scripts/jquery-1.2.6.js" type="text/javascript">script> 
6       <title>Getting Startedtitle> 
7<script type="text/javascript"
8        $(document).ready(function()  
9        { 
10            alert("Using jQuery in ASP.NET"); 
11        }); 
12script> 
13head> 
14<body> 
15    <form id="form1" runat="server"
16    form> 
17body> 
18html> 

Summary

jQuery is a simple, light-weight and fast JavaScript library that has simplified the way you write your scripts these days. It is all set to become the framework of choice for building fast and responsive web applications in the years to come.For additional information on jQuery :

http://docs.jquery.com/Main_Page

http://www.aspcode.net/search/jquery.aspx