Archive for February, 2009

Mapping .html file to ASP.NET

Tuesday, February 24th, 2009

Step one: Open IIS, in your site to set up virtual directory property page tab, click on the “Application Settings (Application Settings)” under the “configuration (Configuration..)” Button, open the “application configuration (Application Configuration ) “window” App Mappings (App Mappings) “Tab page, click on the” Add (Add..) “button, the pop-up” Add / Edit Application Mapping suffix (Add / Edit Application Extension Mapping ) “window, in the” executable program (Executable) “the right of the text box, type C: \ WINNT \ Microsoft.NET \ Framework \ v1.1.4322 \ aspnet_isapi.dll (file path will be. net framework version of the different different for the sake of safety, you can in the “App Mappings (App Mappings)” tab under the list of double-mapping “. aspx”, in the pop-up window to select its “executable program (Executable)” text Copy the text box and then out), in the “name suffix (Extension)” text box you want to add the suffix of “. html”, then click OK to save all open windows to complete the property settings in IIS; 

Step two: open you want to configure the site or virtual directory under the root directory of the web.config file, configuration section in <system.web> add the following configuration sections: 

<httphandlers>
<add verb=”*”
path=”*.html”
type=”System.Web.UI.PageHandlerFactory” />
</httphandlers>


Save web.config file, Now we are set !!! :-)

What Is In The Works For ASP.NET 4.0

Tuesday, February 24th, 2009

A good video here. what is in the works for ASP.NET 4.0. If you are interested in getting some of the latest bits then you may want to take a look over here 

http://www.codeplex.com/aspnet

Video

Configuring Temporary Asp.Net Files Folder

Tuesday, February 24th, 2009

The Temporary ASP.NET Files folder contains all temporary files and assemblies being created to serve pages and resources. You have to look into this subtree to find dynamically created files for your Web pages. Note that the Temporary ASP.NET Files directory is the default location for dynamically created files, but this location is configurable on a per-application basis using the section in the web.config file:

<compilation tempDirectory="d:\MyTempFiles" />

Given below is figure illustrates the default location for the temporary ASP.net folder

asp_temp

Source : Click here…

ASP.NET MVC 1.0 Release Candidate Now Available

Friday, February 20th, 2009

Today we shipped the ASP.NET MVC 1.0 Release Candidate (RC).  Click here to download it (note: the link just went live so if it isn’t working wait a few minutes for the server you are hitting to refresh).  It works with both Visual Studio 2008 and Visual Web Developer 2008 (which is free).

Today’s RC is the last public release of ASP.NET MVC that we’ll ship prior to the final “1.0” release.  We expect to ship the final ASP.NET MVC 1.0 release next month.

In addition to bug fixes, today’s build includes several new features.  It also includes some refinements to existing features based on customer feedback.  Please read the release notes that ship with the ASP.NET MVC download for full details on all changes.  The release notes include detailed instructions on how to upgrade existing applications built with the ASP.NET MVC Beta to the RC.

Read More.. 

AJAX Registration Page

Wednesday, February 18th, 2009

Here AJAX Registration Page with HTML & Javascript. Checking username, length, password match..

live_previewLive Preview downloadDownload

$(document).ready() :

The most commonly used command in jQuery is $(document).ready(). It makes sure code is executed only when a page is fully loaded. We often place code blocks inside this $(document).ready() event.

?View Code JAVASCRIPT
 
<script type="text/javascript" src="jquery-1.2.6.min.js"></script>
 
// Your Code
 
$(document).ready(function()
 
{
 
// Put all your jQuery goodness in here.
 
}

Checking Username Length:

When guest types something in Username field less than 3 characters and focus move from it to next field. An error will be occurred .

username3

?View Code JAVASCRIPT
 
usr = $("#txt_username").val();
 
if(usr.length >= 3) //checking username length
{
	// Checking username code here..
}
 
else
{
	//Error Message code here..
 
}

Chekcing Username:

When guest types something in Username field greater than or equal 3 characters and focus move from it to next field Then, A waiting message will be displayed with small image as loader.gif.

checkingusername

?View Code JAVASCRIPT
$("#div_status").html('<img src="loader.gif" align="absmiddle">&nbsp;Checking username....');

If Username is available:

if username available from database. Ajax will display like this, Otherwise, An error will be occurred.

usernameready

?View Code JAVASCRIPT
	$.ajax({
    type: "POST",
    url: "check_username.php",
    data: "username="+ usr,
    success: function(msg){
   $("#div_status").ajaxComplete(function(event, request, settings){
 
	if(msg == 'OK')
		{
			// If the username available, goes here.
		}
		else
		{
			//If the username not available, goes here.
		}

Checking Password:

When guest types something in password field less than 3 characters and focus move from it to next field. An error will be occurred .

password3

?View Code JAVASCRIPT
 
var str_confirm_password = $("#txt_confirm_password").val();
 
if(str_password.length  >=3)
{
	// Checking Password match code here..
}
else
{
	// Error message code here..
}

Checking Password Match:

When guest types something in Password & Confirm Password fields, and focus move from it to next field. Then, it will check value of both fields. If both field’s value are not same then, an error will be displayed.

If not match

passwordnotmatch

If match

passwordready

?View Code JAVASCRIPT
var str_password = $("#txt_password").val();
var str_confirm_password = $("#txt_confirm_password").val();
 
if(str_password!=str_confirm_password)
{
	// If not match, goes here,
}
else
{
	//If match, goes here.
}

“Sign Up Now” Button :

When guest push “Sign Up Now!” button. It goes to next page .

?View Code JAVASCRIPT
function fn_onclick() {
	if(str_status == "OK" && str_pwd_status =="OK" && str_password != '' && str_confirm_password != '' )
	{
		$("#div_msg").html('<div id="logged_in"> <br />' +
    	 'Thanks for Registering <br />' +
   		  '<img align="absmiddle" src="loader_bar.gif">' +
    	 '<br /> Please wait while we redirect you to welcome page...</div>');
 
		setTimeout('go_to_next_page()', 4000);
	}
}
 
function go_to_next_page()
{
	window.location = 'welcome.html';
}

.removeClass() & .addClass() functions :

.removeClass() & .addClass() functions are used for add styles into username & password fields. In code, ‘css_ok’ & ‘css_error’ regarding from ‘style.css’ . For instance these functions show the box green if the values entered in the boxes are correct & otherwise red color

.

?View Code JAVASCRIPT
<link rel="stylesheet" type="text/css" href="style.css" />
 
	// Your code here..
 
$("#txt_username").removeClass('css_ok');
$("#txt_username").addClass("css_error");

In style.css,

.css_ok
{
border: 1px solid green;
color: #333333;
}
.css_error
{
border: 1px solid #AC3962;
color: #333333;
}

live_previewLive Preview downloadDownload

Security Audit Events in ASP.NET 2.0

Tuesday, February 17th, 2009
Event Description
WebAuditEvent Base class for all audit events.
WebFailureAuditEvent Base class for all failure audit events, which are raised whenever a security action fails. ASP.NET 2.0 raises these events when URL or file authorization fails to authorize the request.
WebSuccessAuditEvent Base class for all success audit events, which are raised whenever a security action succeeds. ASP.NET 2.0 raises these events when URL or file authorization succeeds in authorizing the request.
WebAuthenticationFailureAuditEvent Base class for authentication failure audit events, which are raised whenever an authentication attempt fails. ASP.NET 2.0 raises these events when Membership providers or forms authentication fail to validate provided credentials, or when the forms authentication ticket fails to be decrypted or validated.
WebAuthenticationSuccessAuditEvent Base class for authentication success audit events, which are raised whenever an authentication attempt succeeds. ASP.NET 2.0 raises these events when Membership providers or forms authentication succeed in validating provided credentials.
WebViewStateFailureAuditEvent The class for the ViewState failure audit event, which is raised whenever ASP.NET fails to process the ViewState due to an encryption or validation problem.

Source : Click Here…

Download Multiple Files Into One ZIP File

Monday, February 16th, 2009

How to Download Multiple Files Into One ZIP File

downloadDownload ICSharpCode.SharpZipLib.dll

Add this code as Class

using ICSharpCode.SharpZipLib.Zip;

Copy this code to your *.cs file

Pure Ajax in Asp.Net 4.0

Monday, February 16th, 2009

Here is an interesting article on pure Ajax in Asp.Net 4.0.This article claims that the previous versions of Ajax is not partial post back.


Ajax Based Search Engine With PHP and XML

Sunday, February 15th, 2009

Here Sample code of Ajax based search engine with PHP and XML

live_preview Live Preview          downloadDownload Code

 

This is the Javascript Code :

?View Code JAVASCRIPT
/* &lt;--------------------------&gt; */
/* XMLHTTPRequest Enable		*/
/* &lt;--------------------------&gt; */
function createObject() {
var request_type;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
request_type = new ActiveXObject("Microsoft.XMLHTTP");
}else{
request_type = new XMLHttpRequest();
}
return request_type;
}
 
var http = createObject();
 
/* &lt;--------------------------&gt; */
/* 		SEARCH				   */
/* &lt;--------------------------&gt; */
 
function fnSearchName() {
 
txtInput=encodeURI(document.getElementById('txtInput').value);
 
document.getElementById('divmsg').style.display = "block";
document.getElementById('divmsg').innerHTML = "Searching for <strong>" + txtInput+"</strong>";
// Set te random number to add to URL request
nocache = Math.random();
http.open('get', 'php_Search.php?name='+txtInput+'&amp;nocache = '+nocache);
 
http.onreadystatechange = fnSearchNameReply;
http.send(null);
}
function fnSearchNameReply() {
 
	var response = http.responseText;
	document.getElementById('divResult').innerHTML=response;
 
}

This is the PHP Code :

load("NameList.xml");
$x=$xmlDoc-&gt;getElementsByTagName('NAME');
for ($i=0; $i&lt;=$x-&gt;length-1; $i++)
{
//Process only element nodes
if ($x-&gt;item($i)-&gt;nodeType==1)
  {
  if ($x-&gt;item($i)-&gt;childNodes-&gt;item(0)-&gt;nodeValue == $q)
    {
    $y=($x-&gt;item($i)-&gt;parentNode);
    }
  }
}
$cd=($y-&gt;childNodes);
for ($i=0;$i&lt;$cd-&gt;length;$i++)
{
//Process only element nodes
if ($cd-&gt;item($i)-&gt;nodeType==1)
  {
  echo($cd-&gt;item($i)-&gt;nodeName);
  echo(": ");
  echo($cd-&gt;item($i)-&gt;childNodes-&gt;item(0)-&gt;nodeValue);
  echo("");
  }
}
 
?&gt;

Add/Remove NewLine in SQL Query

Friday, February 13th, 2009

Add NewLine in SQL Query:

 
  Code:
Declare @FristName Char(10)
Declare @LastName Char(10) 
 
Set @FristName = 'Venu'
Set @LastName = 'Thomas' 
 
Select (@FristName + CHAR(13) + CHAR(10)+ @LastName) As Name
   

OutPut:

Name  
———————- 
Venu      
Thomas    

(1 row(s) affected)
 

Remove NewLine in SQL Query:

Code:


Declare @FristName Char(5)
Declare @LastName Char(10) 
Declare @strName Char(15) 
 
Set @FristName = 'Venu'
Set @LastName = 'Thomas'  
 
Set @strName =@FristName + CHAR(13) + CHAR(10)+ @LastName 
 
Select Replace(Replace(@strName, CHAR(13), ''), CHAR(10), ',') As Name
   

OutPut:

Name
————
Venu ,Thomas
(1 row(s) affected)