Archive for ASP.NET

Codeproject Highlight

Do you want to be informed the best stuffs of Codeproject every months? I have one good news for you. I’m gonna launch one new program called “Codeproject Highlight” started from this month in my blog. In this program, there will be there parts such as news, the best articles and the best posts in CP forum (mostly are from ASP.NET, Web development and C#. ).

The main reason why I start this program is that it saves your time for reading all of latest articles from CP’s feed and tracking all questions and answers from Codeproject forum.

News

Site Upgrading

The whole Codeproject site has been upgraded from Classic ASP to ASP.NET version with a lot of improvements . This is really big changes which is done during 8 years of running. As this site has really huge amount of traffic, it’s very hard for them to upgrade this site with new version. However, the CP development team has done the great job to upgrade the whole site successfully. Congratulation! CP team

Chris shared a few interesting things here ~

For those interested here are some whacky and amusing things we found:

  • SQL Server, IIS and the ASP.NET framework are possessed.
  • Using development settings instead of production settings is a Bad Thing.
  • Storing session state in a SQL database can be a performance killer. Especially when the database is an old P4 test harness machine 40 km away from the webserver. That was an interesting experience in scream therapy.
  • Always check your indexes. Especially the ones that absolutely positively are not and cannot be fragmented. They will be the ones most in need of attention.
  • 20,000 users hitting your application is wonderful load testing. We did load test but our testing machines did not generate the load you guys can generate
  • no matter how many ways you check code there’s always an angle that you haven’t looked at. We’re finding errors in 10 mins of being on that we couldn’t find from 3 months of beta testing. This is just nature.

The Best Articles

  • Silverlight 1.1 Fun and Games by Sacha Barber

    Silverlight Game and Fun

    Sourcecode : Download Source

    Note: This is an award-winning article of Visual Studio 2008 Competition.

  • Silverlight Alien Sokoban by Daniel Vaughan

    A fun Silverlight implementation of the game Sokoban. Contrasting Silverlight 1.1 and WPF, while showcasing some new features of C# 3.0, Expression Design, Expression Blend, and Visual Studio 2008.

    Silverlight Alien Sokoban

    Sourcecode : Download Source

  • Build Google IG-like Ajax Start Page by Omar Al Zabir

    Build a start page similar to Google IG in 7 nights using ASP.Net Ajax, .NET 3.0, Linq, DLinq and XLinq.

    Google IG

    Sourcecode : Download Source

    Demo : Ajax Web Portal

  • WCF / WPF Chat Application by Sacha Barber

    How to create a peer-to-peer chat application using Windows Communication Foundation

    Free Chatting Client in .NET

    Sourcecode : Download Source

  • ASP.NET Popup Control by Tomas Petricek

    Highly customizable JavaScript popup control for web page wrapped in ASP.NET custom control.

    ASP.NET Popup Control

    Sourcecode : Download Source

Links

The best posts in Codeproject forum

  • How to store the password in Database? Encrypting Vs Hashing, Salt

    This is a discussion about storing the password in database. As the user authentication used to be a part of almost every software system, the developers should have good understanding about how to store the password in database. We have discussed about encrypting vs hashing, adding salt or adding the user name after the password and etc.

    Summary

    • Don’t use encryption/decryption for password.
    • Don’t need to append the user name to the password.
    • Hashing the password with random salt (SHA2 might be the best for hashing.)

    You can read about it in the link below.

    Read More ~ guidelines on password encryption

  • Does the System.Deployment namespace cover a great deal of scenarios?

    I have been asked this question regarding ClickOnce deployment in CP forum. As I’m using ClickOnce APIs on SCSF (Smart Client Software Factory) project, I found a few missing things in System.Deployment namespace. The following are the things that ClickOnce can’t handle.

    Summary

    • No way to get the list of latest modules
    • The version of the whole application need to be updated if we wanna update just one module
    • ClickOnce doesn’t care about the version of assemblies.
    • DownloadFileGroup (”") works only if “optional” is checked. There is no way to download the group of file by force

    Read More ~ An application that will get the updates from server automatically

  • ADODB.DataTypeEnum.adBigInt problem “Bad variable type!” in Windows 2000

    One people who are using ADODB in .NET asked the question below in our CP forum.

    The identity field of one of my SQL DB tables is a bigint, using ADODB to query the DB based on this bigint works fine in my XP machine, but gives me a “Bad variable type” error when I use my app in a W2000 machine.

    The W2000 machine has every service pack issued by MS, what could be the problem?

    Something works fine on XP doesn’t work on Windows 200 is very strange issue. As I never use ADODB (something that we used for VB6 projects in old days ) in .NET, I don’t have that experiences. The possibilities that I think of at that time did solve his problem.

    The trick is that casting the original datatype (long datatype in his case) to double datatype. :) Honestly, I’m not so sure why we need to do this but it did solve the problem.

    
    Cmd.Parameters.Append(Cmd.CreateParameter("TransId", ADODB.DataTypeEnum.adBigInt, 1, , CType(iTransId, Double)))
    

    Read More ~ In XP works fine, W2000: Bad variable type!

Okay. That’s all for now. This is just a taste of new thing in my blog. What do you think? Is it interesting? As this program is just started, your feedback is highly appreciated. I think that there are a few area that I can’t add in this post. Based on the feedback from all of you, I will make this program better and interesting.. If you like it, don’t forget to subscribe my feed ( http://michaelsync.net/feed ).

Thanks.

Script# - Is Script# right for you?

I was playing a lit bit with Script# and I have some thoughts that I wanna share you. ( If you have no idea about what Script# is then you can read this post “Script#: C# to Javascript converter[^] “. ) I know that Script# is a great framework but it might not be right for all ASP.NET developers. The reason is that there are a few things which are not so convenience for me while I’m using Script#. But I don’t want to say that this framework is not for you. maybe, you might like it. In fact, I will give some facts that I’ve learnt about Script#. You decide whether Script# is right for you or not.

Contents

  1. Script#’s features
  2. Writing the object-oriented code with Script#
  3. Tools for generating the documentation and compressing the sourcecode
  4. What we meant by Script# as a C# to Javascript Converter is ~
  5. Script# as a new language
  6. Debugging problem in Script#
  7. Script# is not from Microsoft
  8. Script# is not Opensource
  9. Using the thirt-party Javascript library in Script#
  10. Script# for ASP.NET Ajax developers and Vista Gadget developers

1. Script#’s features

Script# supports the compile-time checking, intelliSense, class-viewer, reflection and etc. It helps you not to have any typo-errors (e.g. calling foo’() instead of foo(); foo(arg1, arg2) instead of foo(arg1); ) that the most of Javascript developers used to make. So, the benefit of using Script# is that it will improve your productivity.

intellisense.jpg
Fig: intelliSense

tooltip.jpg
Fig: Tooltip

Script# - Compile-time Validation
Fig: Compile-time validation

2. Writing the object-oriented code with Script#

Writing the object-oriented Javascript become so easy with Script#. As you know, writing the object-oriented code in Javascript and C# are quite different. If you are not so familiar with Javascript, you probably need to find the reference when you need to write the code with object-oriented concept. Now, it’s over. You can just write the object-oriented code in C# and Script# will convert this code to the object-oriented Javascript code.

3. Tools for generating the documentation and compressing the sourcecode

If you are using Script#, you won’t need any third-party tool (e.g. JSDoc, Javascript Compressor) for generating the documentation or compressing your javascript library. Script# already has the build-in feature for that purpose.

4. What we meant by Script# as a C# to Javascript Converter is ~

This is very important thing you need to understand before you start learning about Script#. As I said in my previous article, Script# is able to convert the C# code to Javascript. But it doesn’t mean that it can convert all C# code that you wrote in winform or webform. In order to convert the C# to Javascript via Script#, you have to write the Script#-specific code in C# then those codes will be converted to Javascript…

5. Script# as a new language

The syntax of Script# is not so similiar to the Javascript’s syntax. So, I feel like learning a new language to write the Javascript. Another problem is that it is so hard to find the equivalent syntax in Script#.

For example: How to access ‘document’ of created DOMElement??[^]

In Javascript,


var iframe = document.createElement("iframe");
var doc = iframe.contentWindow.document;

In Script#,


using System;
using System.DHTML;
using ScriptFX;
using ScriptFX.UI;

public class MyScriptlet {

public static void Main(ScriptletArguments arguments) {
DOMElement _iframe = Document.CreateElement("iframe");
DOMElementExt contentWindowElement = (DOMElementExt)_iframe.GetAttribute("contentWindow");
DOMElement doc = contentWindowElement.document;

}
}

[IgnoreNamespace]
[Imported]
public class DOMElementExt : DOMElement {

[IntrinsicProperty]
public DOMElement document {
get { return null; }
}

[IntrinsicProperty]
public DOMElement body {
get { return null; }
}

[IntrinsicProperty]
public DOMElement src {
get { return null; }
}

[IntrinsicProperty]
public DOMElement firstChild {
get { return null; }
}
}

If you look at both examples, you will understand how hard to find the equivalent syntax in Script#. It’s okay if we can find the equivalent one. But what if Script# doesn’t support something that can be done with Javascript?

6. Debugging problem in Script#

Script# does support the compile-time validation but the problem is that you won’t be able to debug the C# code that you wrote. Instead, you will have to debug the Javascript code that generate by Script#. I think that it is the big issue for web developer. I don’t feel comfortable to debug those generated code.

7. Script# is not from Microsoft

Script# is not developed by Microsoft while the GWT is developed by Google. It has too much differences. Even thought Nikhil is an architect from Microsoft, Script# is just one of his pet projects.. So, I don’t think that he is gonna support his pet project all the time.. And I’m not so sure that Nikhil will add more features to this project or not..

8. Script# is not Opensource

Script# is not an opensource project. Actually, it’s absolutely okay for me to use the non-opensource projects (I’ve been using the Visual Studio since long long ago.) but there should be a group of people who are supporting this project, right? What if we need the bug-fixed?

9. Using the thirt-party Javascript library in Script#

The most of Javascript libraries /framework (e.g. prototype, script.aculo.us, Yahoo.UI, ExtJS) are not written in Script#. So, you can’t use those libraries right away from your Script# code. I think you will have to create a wrapper class for those libraries in order to use them in your Script#-enabled projects.

10. Script# for ASP.NET Ajax developers and Vista Gadget developers

I think that Script# might be good for ASP.NET Ajax developers and Vista Gadget developers. As I’m not very familiar with those things, I’m not able to cover about this. I need your contributes for this fact.

Okay That’s all from my side. Feel free to let me know if you have any thought or comment. Thanks.

Script#: C# to Javascript Converter

Have you heard about Script#? I heard about this toolkit last week even Nikhil started this project last year. I knew that there is a Java-to-Javascript converter called GWT (Google Web Toolkit) in Java World since long time back and I thought that it might be good if we, the C# developers, also have that kinda tools for ASP.NET web development. Now, the dream come true. Nikhil created Script# project that can convert the C# code to Javascript. I think it is pretty interesting (and strange ) tool and I wonder how Script# will convert the C# code to Javascript. Anyway, I started learning about Script# on last Friday. I’m gonna share what I have learnt about it so far. If you are already familiar with this tool, please share your thoughts about this tool. Thanks.

Introduction

Script# is a compiler that generate the Javascript instead of MSIL (Microsoft Intermediate Language) from C# sourcecode. Like GWT (Google Web Toolkit) that can convert the Java code to browser-compliant JavaScript and HTML, Script# is able to convert the C# codes to Javascript (either human-readable format or compact one). It is the best tool for those who hate to write the Javascript in HTML view.

Sourcecode Download : SSharp.zip

Example 1 : Getting Started with Script#

  • Download the ScriptSharp.zip from this link.
  • Extract it and double-click ScriptSharp.msi to install the Script# (You should note that Script# is currently available for Microsoft Visual Studio 2005. If you wanna use Script# with Visual Studio 2008, please check-out this post.)
  • Launch the Microsoft Visual Studio 2005 IDE and let’s create very sample Script# project
    Note: I recommended you to run the VS 2005 IDE as an administrator if you are using Windows Vista series.

  • Click “Script#-Enabled Web site” Project Template from “New Web Site” dialog (File>New>Web Site)
  • We will create one button named “clickMeButton” and the div called “greetingDIV” within
    tag.
    
    <div>
    <input type="button"  id="clickmeButton" value= "Click Me" />
    <br />
    <br />
    <div id="greetingDIV" class="divbox">
    Hello buddy!!
    </div>
    </div>
    
  • Go to the design-view and right-click on “Scriptlet” control as picture belowScript# - Scriptlet Control
  • Select “Edit C# Code” on content menu.
  • Paste the following code in Scriptlet Editor
    
    using System.DHTML;
    using ScriptFX;
    using ScriptFX.UI;public class MyScriptlet : IDisposable {private DOMEventHandler _clickHandler;
    
    private MyScriptlet(ScriptletArguments arguments) {
    _clickHandler = new DOMEventHandler(OnClickMeButton_Click);
    
    DOMElement clickMeButton = Document.GetElementById("clickmeButton");
    clickMeButton.AttachEvent("onclick", _clickHandler);
    }
    
    public static void Main(ScriptletArguments arguments) {
    MyScriptlet scriptlet = new MyScriptlet(arguments);
    
    }
    
    public void Dispose() {
    if (_clickHandler != null) {
    DOMElement okButton = Document.GetElementById("clickmeButton");
    okButton.DetachEvent("onclick", _clickHandler);
    _clickHandler = null;
    }
    }
    
    private void OnClickMeButton_Click() {
    DOMElement divGreeting = Document.GetElementById("greetingDIV");
    divGreeting.Style.Display = "block";
    }
    }
    

    Script# - Scriptlet Editor

  • Click “Save and Close” on Scriptlet Editor
  • Build the web application and Press “F5″ to run the application
  • (There is one button on the page.) Click this button.
  • “Hello Buddy!” message will be shown as picture below.Script# - Example 1

That’s.. You just created one script#-enabled webpage. Do you want to know what code Script# generated from your C# code? It’s easy. Just go to “View Source” and you will see the following script which is generated by Script#.


<script type="text/javascript">
//<![CDATA[
window.main = function main() {
Type.createNamespace('Scriptlet');

////////////////////////////////////////////////////////////////////////////////
// Scriptlet.MyScriptlet

Scriptlet.MyScriptlet = function Scriptlet_MyScriptlet(arguments) {
this._clickHandler = Delegate.create(this, this._onClickMeButton_Click);
var clickMeButton = $('clickmeButton');
clickMeButton.attachEvent('onclick', this._clickHandler);
}
Scriptlet.MyScriptlet.main = function Scriptlet_MyScriptlet$main(arguments) {
var scriptlet = new Scriptlet.MyScriptlet(arguments);
}
Scriptlet.MyScriptlet.prototype = {
_clickHandler: null,

dispose: function Scriptlet_MyScriptlet$dispose() {
if (this._clickHandler) {
var okButton = $('clickmeButton');
okButton.detachEvent('onclick', this._clickHandler);
this._clickHandler = null;
}
},

_onClickMeButton_Click: function Scriptlet_MyScriptlet$_onClickMeButton_Click() {
var divGreeting = $('greetingDIV');
divGreeting.style.display = 'block';
}
}

Scriptlet.MyScriptlet.createClass('Scriptlet.MyScriptlet', null, IDisposable);

// ---- Do not remove this footer ----
// Generated using Script# v0.4.2.0 (http://projects.nikhilk.net)
// -----------------------------------

ScriptFX.Application.current.run(Scriptlet.MyScriptlet);
}
ScriptHost.initialize([
'App_Scripts/ssfx.Core.js',
'App_Scripts/ssfx.UI.Forms.js'
]);
//]]>
</script>

Don’t you think that the generated Javascript code looks so similar to your C# code that you wrote in Scriptlet Editor? Yes. This is one of the advantages of using Script#. It can generate the human-readable Javascript that has the same structure as your C# code. If you are not sure how to write the object-oriented code in Javascript, you can just write the code in C# with the rich features such as IntelliSense, refactoring, compile-time and let Script# convert the C# code to the object-oriented Javascript code.

Note: The sample is already attached in this post. Please check-out “Example1.aspx” in zip file.

Okay. We’ve just done one sample with Script#. As the project is in very early stage, I notice that there are a few weak points and bugs in that project while I’m learning. And also, I’m kinda agreed with Dimitri Glazkov regarding on Script# project. (Check-out his post here.) Anyway, let’s learn more about Script# and we’ll see whether we should use it in real project or not.

Example 2 : Script# Ajax

  • Create the another Script#-enabled project
  • Add the “Generic Handler” to your project and name it “ExampleWebHandler.ashx”
  • Paste the following code in “ProcessRequest (HttpContext context)” function.
    
    context.Response.ContentType = "text/xml";
    context.Response.Write("Hi " + HttpUtility.HtmlEncode(context.Request.QueryString["name"]) + "!");
    

    Note: What this code does is that write the “Hi” after appending the name that came as a parameter in response.

  • Add one textbox to accept the user inputs, one button to invoke the server-side script and the div for displaying the result
    
    <div>
    Please Enter your name : &nbsp;&nbsp;
    <input type="text" id="nameTextBox" /> &nbsp;&nbsp;
    <input type="button" id="sayHiButton" value="Say Hi!!"/> <br /><br />
    <div id="result">
    </div>
    </div>
    
  • Add the argument to your scriptlet control. (Right-click on Scriptlet control and select “Edit” Arguments. then, Add one member (Name: name and Value: ExampleWebHandler.ashx?name={0}))

    Edit Arguments - ScriptletArgument Collection Editor

  • then, Click “OK” to close the “ScriptletArgument Collection Editor”
  • Paste the following code in “Scriptlet Editor”
    
    using System;
    using System.DHTML;
    using ScriptFX;
    using ScriptFX.UI;
    using ScriptFX.Net;
    
    public class MyScriptlet : IDisposable {
    
    private string _urlName;
    private DOMEventHandler _clickHandler;
    private XMLHttpRequest _request;
    DOMElement resultDIV = null;
    
    public static void Main(ScriptletArguments arguments) {
    MyScriptlet scriptlet = new MyScriptlet(arguments);
    }
    
    public void Dispose() {
    if (_clickHandler != null) {
    DOMElement okButton = Document.GetElementById("sayHiButton");
    okButton.DetachEvent("onclick", _clickHandler);
    _clickHandler = null;
    }
    if (_request != null) {
    _request.Onreadystatechange = (Callback)Delegate.Null;
    _request.Abort();
    _request = null;
    }
    }
    
    private MyScriptlet(ScriptletArguments arguments) {
    _urlName = arguments.name;
    
    _clickHandler = new DOMEventHandler(OnSayHiButton_Click);
    
    DOMElement clickMeButton = Document.GetElementById("sayHiButton");
    clickMeButton.AttachEvent("onclick", _clickHandler);
    }
    
    private void OnSayHiButton_Click() {
    InputElement nameTextBox = (InputElement)Document.GetElementById("nameTextBox");
    resultDIV = Document.GetElementById("result");
    resultDIV.Style.Display = "block";
    
    _request = new XMLHttpRequest();
    _request.Onreadystatechange = this.OnRequestComplete;
    _request.Open("GET", String.Format(_urlName, nameTextBox.Value.Escape()), /* async */ true);
    _request.Send(null);
    }
    
    private void OnRequestComplete() {
    if (_request.ReadyState == 4) {
    //if (_request.Status == 200) {
    _request.Onreadystatechange = (Callback)Delegate.Null;
    if (resultDIV != null) {
    resultDIV.ClassName ="divbox";
    resultDIV.InnerHTML = _request.ResponseText;
    }
    _request = null;
    // }
    }
    else {
    if (resultDIV != null) resultDIV.InnerHTML = @"<img src=""./images/indicator_technorati.gif"">";
    }
    }
    }
    

    Note: I assumed that you already have some ideas about Ajax before reading this article.

  • Build the application and run it. (You will see one textbox and one button as you have added on the page.)
  • Type the name you like
  • Click “Say Hi!” button. (You will see the result as below with the name that you enter.)

This demo is very sample that shows the way how to communicate between Script# code and the Server-side code. You can probably extends the web handler to get the more features as you need for your Script#-enabled application.

Debugging the Script#-enabled application

For IE Users, Go to “Debug->Windows->Script Explorer” or Press “Ctl+Alt+N” while you are running the project. You will see the list of script files that are included in page. Select the script file that you wanna debug and set the breakpoint. You know how to debug the Javascript with Visual Studio 2005, right?

For Firefox Users, Firebug is the best tool for debugging the Javascript.

Yeah. It is so sad to say that you are not able to debug the C# code that you wrote. Instead, you will be debugging the Javascript code which is generated by Script# compiler.. It makes you feel like debugging the MSIL code after writing the C# in IDE even the generated code is so much like the C# code that you wrote and human-readable but it is by-design so we can do nothing.

Conclusion

I’m gonna stop learning the Script# project for today. I’ll read about building the Script# library and Vista Sidebar Gadget and will post them in my blog. For the time being, I do have a few disappointments in using Script#. However, I will look more information about this project and I will share the conclusion with you.. If you are also learning this project like me, please let me know. We can probably discuss more about this project.. Thanks…

More Information about Script# ~

How to protect the image from being copied?

Well, it is so sad to say that there is no way to protect the images from being copied until the time of writing this post. You may probably tell me that you found a lot of “Image Protection” tools on web. Yeah. I know. I did even tried some of them once. Those tools make people difficult to copy the images from your website. but there are always some sort of hecks for copying images. No matter what tools or technologies you use.

I will tell some attempts that people tried to achieve this goal and the reason why those attempts were failed.

#1. Disabling “Right Click” on webpage by using Javascript.

This is very very old trick and it’s totally useless. Don’t forget “Save As” in File menu. Plus, there are a lot of DOM manipulators (eg: Firebug) to track the path of images.

#2. Adding new transparent image over the actual image

I found some sites (including flickr) that are using this technique to protect their images from being copied. It works for normal users who only knows “Right Click” and “Save Image As”. You can still check the source to get the correct path of actual image that you want. If you are familiar with firebug, you can easily delete the transparent image that you don’t want on the fly.

#3. Using third-part tools for image protection

If you do googling about this a lit bit, you will get a ton of tools advertising that those tools will help you to protect your image from being copied (some even said that those tools are able to protect HTML code too.) Don’t even never spend your money on those tools. I mean it. As I said above, I tried already. I know those tools are not good enough since they have their own limitations. So, don’t waste your money on it.

This fact applied for code protection tool also. Those tools are going to encrypt your webpage and will add a lot of whitespace in your actual source. So, if you check the “View Source” a lit in your browser, you will see plain text or some text you write instead of HTML code. but don’t forget to scroll a lit bit.. You will see goddammed things.. and those tools will eat your bandwidth and it made your visitors to view the web page in slow motion. :)
#4. Putting images in Embedded Object (Flash or ActiveX Object)

I think this is the best way to protect the image so far. but it is possible to download the whole flash file (*.flv) to local machine by using third-party tool or firefox extensions (eg: Download Helper). So, the individual image are safe from being copied but not for flash.

UPDATED (27th August, 2007):

Watermarking (Thanks to mmhan for reminding me about this.)

AFAIK, there are two ways of watermarking. The first way is that putting a watermark simply on the image. This watermark will be visible to everybody. The second way is that putting a invisible watermark on the image by using Steganography.

Yeah. those are the ways that I remember how people tried to protect their images. If you have other ways, don’t hesitate to let me know.

Remember! All images from the webpage are already sent to the temporary internet files of user’s local machine before showing to the web browser. So, user can still copying images from Temporary Internet File folder. And, What about “Print Screen”? :)
So, if you ask me how to protect the image, I would say “don’t do that!” . :)

ASP.NET: DropDown List problem with IE6

SourceCode Download ~

WebSite7
Hosted by eSnips

Question ~

One member from Codeproject asked ~

Hi all,

There is a small requirement in drop down list. Suppose I have bounded the employee names to the drop down list. Now I am searching for a name “Peter”. So if I press ‘p’ and then ‘e’ it should go to Peter’s name. But it goes to Elizabeth’s name. Is there any solution for that? Could anyone of you please help me on that? I am using .Net version 2.0

Thanks and Regards,
Hariharan C

Solution ~

This issue occurs in Internet Explorer 6 version only. I have tested this issue with the most of browsers (Internet Explorer 7, Firefox 2.0.0.6, Opera 9.2 and Safari 3.0.3 (Windows).) It works fine except IE6. I looked for the solution and I came up with the following code.


var pressedKeyString = "";
var delay = 1000;
var timeID = null;

function move(){
var selectList = document.getElementById('DropDownList1');
var arr = new Array();
var idx = 0;
for(var i = 0; i = pressedKeyString.length){
if(pressedKeyString.toLowerCase() == selectList.options[i].value.substring(0,pressedKeyString.length).toLowerCase()){
selectList.selectedIndex = i;
i=selectList.options.length;
alert(pressedKeyString);
}
}
}
pressedKeyString = "";
}
function foo(e,id){
if(timeID != null)clearTimeout(timeID);
timeID = setTimeout("move();",delay);
var key;
if(window.event) // IE
{
key = e.keyCode
}
else if(e.which) // Netscape/Firefox/Opera
{
key = e.which
}
var pressKey = String.fromCharCode(key);
pressedKeyString += pressKey;
}

The main idea of this code is that we will enable the timer to check whether the user is still typing or not. The timer will get clear as long as the user keep on typing. The character that you typed will keep on appending to the string called pressedKeyString. Note that the select list will be changed automatically on IE6 by default while typing. (Ya, this is what we don’t like). After typing finished (timer will count to 1000 minisecound), then the dropdown list will be changed to the option which is matched with the characters that you enter. (eg: if you type “pe” then dropdown list will select to “Peter”.)

Hope it helps. Feel free to let me know if you have any comment or suggestion. Thanks.

Some interesting ASP.NET 2.0 FAQ

I found this post <I’m wondering - asp.net 2.0> on Mayvelous’s blog. I think those questions are very interesting. So, I was thinking to write the reply post for those questions but I didn’t have the exact answer for the generated xml file of .dll. I didn’t have time to find about that too. So, the post was saved as a draft in my blog for long time. I accidentally found this post in wp drafts collection yesterday. I made some changes today and post it here..

Why ASP.NET 2.0 website project does not create project file?

In ASP.NET 1.1, the configuration information of project used to store in *.csproj. If it’s a web project, the URL part is saved in *.webinfo. But it has been changed in ASP.NET 2.0. All of project configuration, path (both absolute part or virtual part) are stored in *.sln file only.

Why ASP.NET 2.0 webproject doesn’t create .dll file? Where all those code-behinds compiled into?

ASP.NET web pages and code files are dynamically compiled on request for the first time. The compiled resources are cached for next time request. So, no need to generate .dll for webproject. But It’s not good pratice and nobody won’t do that on their production server. Once I did it like that to know how bad that is. What I did was that I copied the whole folder of my website from my harddrive and uploaded it in FTP. Then, I tried to browse my website. It was very slow. I didn’t use any thrid-party components in that website. I think it will be more obviously slow if there are some third-party components used in website.

You should precompile your website if you wanna see *.dll file of your project. As you know, Precompilation is new features of .NET 2.0 which allows developers to precompile the entire website for boosting response time of your website.

Advantages of Precompilation (Ref: MSDN )

  • Faster response time for users, since pages and code files do not have to be compiled the first time they are requested. This is particularly useful on large sites that are updated frequently.
  • A means to identify compile-time bugs before users see a site.
  • The ability to create a compiled version of the site that can be deployed to a production server without source code.

More Info ~

>>I’m wondering, if we are to deploy it, do we only deploy .aspx and .ascx (front-end) files or have to include code-behind files as well?

not “have to” but you can if you want. Like I said above, you can include code-behind files in deployment. but it’s not good. Precompilation would be the best.

>>I’m wondering, why .pdb files are also included when you add project references to the website project.pdb files

AFAIK, this .pdb file is automatically generated if the Project configuration is set to “Debug” Mode. This file is used for storing the debugging information and symbols. Honestly, I dont have that much idea about this file. Please check .pdb file - MSDN for more info.

>>I’m wondering, do we need to add those .pdb and .xml along with referenced .dll in the deployment.

No. It’s not required. I’m sure that it’s not required to add those files in deployment but I dont know why xml files are generated. So, I have asked about it in CodeProject Forum. I got the answer as below from Scott Dorman in very short time. (Thank you! scott. )

The *.xml file is the compiler generated XML documentation file. The contents of this file come from the XML comments in the source code.

The *.pdb file is the debugging symbol file, also generated by the compiler. It contains the debugging “symbols” (information) needed by the debugger to be able to match the compiled binary to the source code when you are debugging.

>> I’m wondering, the main difference between asp.net 2.0 web application project and web site project.

AFAIK, asp.net 2.0 web application project is designed for those who wanna keep VS 2003 web project model. But I’m not very interest to use this since it doesn’t support in VS 2005 Express Edition. Here is the good article about Web Application Project and the differences between Web Application Project and Web Project.

Feel free to let me know if you have any comment for those answers. I’m just sharing in the way that I understand. If you have some more idea about those then feel free to discuss with me. Thanks.