Friday 3 June 2011

Javascript Code: Clock


</SCRIPT>

<SCRIPT language=JavaScript>

fCol='444444'; //face colour.
sCol='FF0000'; //seconds colour.
mCol='444444'; //minutes colour.
hCol='444444'; //hours colour.

Ybase=30; //Clock height.
Xbase=30; //Clock width.


H='...';
H=H.split('');
M='....';
M=M.split('');
S='.....';
S=S.split('');
NS4=(document.layers);
NS6=(document.getElementById&&!document.all);
IE4=(document.all);
Ypos=0;
Xpos=0;
dots=12;
Split=360/dots;
if (NS6){
for (i=1; i < dots+1; i++){
document.write('<div id="n6Digits'+i+'" style="position:absolute;top:0px;left:0px;width:30px;height:30px;font-family:Arial;font-size:10px;color:#'+fCol+';text-align:center;padding-top:10px">'+i+'</div>');
}
for (i=0; i < M.length; i++){
document.write('<div id="Ny'+i+'" style="position:absolute;top:0px;left:0px;width:2px;height:2px;font-size:2px;background:#'+mCol+'"></div>');
}
for (i=0; i < H.length; i++){
document.write('<div id="Nz'+i+'" style="position:absolute;top:0px;left:0px;width:2px;height:2px;font-size:2px;background:#'+hCol+'"></div>');
}
for (i=0; i < S.length; i++){
document.write('<div id="Nx'+i+'" style="position:absolute;top:0px;left:0px;width:2px;height:2px;font-size:2px;background:#'+sCol+'"></div>');
}
}
if (NS4){
dgts='1 2 3 4 5 6 7 8 9 10 11 12';
dgts=dgts.split(' ')
for (i=0; i < dots; i++){
document.write('<layer name=nsDigits'+i+' top=0 left=0 height=30 width=30><center><font face=Arial size=1 color='+fCol+'>'+dgts[i]+'</font></center></layer>');
}
for (i=0; i < M.length; i++){
document.write('<layer name=ny'+i+' top=0 left=0 bgcolor='+mCol+' clip="0,0,2,2"></layer>');
}
for (i=0; i < H.length; i++){
document.write('<layer name=nz'+i+' top=0 left=0 bgcolor='+hCol+' clip="0,0,2,2"></layer>');
}
for (i=0; i < S.length; i++){
document.write('<layer name=nx'+i+' top=0 left=0 bgcolor='+sCol+' clip="0,0,2,2"></layer>');
}
}
if (IE4){
document.write('<div style="position:absolute;top:0px;left:0px"><div style="position:relative">');
for (i=1; i < dots+1; i++){
document.write('<div id="ieDigits" style="position:absolute;top:0px;left:0px;width:30px;height:30px;font-family:Arial;font-size:10px;color:'+fCol+';text-align:center;padding-top:10px">'+i+'</div>');
}
document.write('</div></div>')
document.write('<div style="position:absolute;top:0px;left:0px"><div style="position:relative">');
for (i=0; i < M.length; i++){
document.write('<div id=y style="position:absolute;width:2px;height:2px;font-size:2px;background:'+mCol+'"></div>');
}
document.write('</div></div>')
document.write('<div style="position:absolute;top:0px;left:0px"><div style="position:relative">');
for (i=0; i < H.length; i++){
document.write('<div id=z style="position:absolute;width:2px;height:2px;font-size:2px;background:'+hCol+'"></div>');
}
document.write('</div></div>')
document.write('<div style="position:absolute;top:0px;left:0px"><div style="position:relative">');
for (i=0; i < S.length; i++){
document.write('<div id=x style="position:absolute;width:2px;height:2px;font-size:2px;background:'+sCol+'"></div>');
}
document.write('</div></div>')
}



function clock(){
time = new Date ();
secs = time.getSeconds();
sec = -1.57 + Math.PI * secs/30;
mins = time.getMinutes();
min = -1.57 + Math.PI * mins/30;
hr = time.getHours();
hrs = -1.57 + Math.PI * hr/6 + Math.PI*parseInt(time.getMinutes())/360;

if (NS6){
Ypos=window.pageYOffset+window.innerHeight-Ybase-25;
Xpos=window.pageXOffset+window.inner

.Net Jobs in India, ASP.Net/VB.Net/C#

http://www.naukri2000.com/jobs/dotnet.php

http://www.softwarejobsindia.com/asp.net-jobs-india.html



ASP.NET MVC - Some Frequently Asked Questions

This article introduces ASP.NET MVC and answers some frequently asked questions about ASP.NET WebForms vs ASP.NET MVC. 
What is MVC?
MVC or the Model-View-Controller is an architectural pattern used in software engineering for separating the components of a Web application. The MVC pattern helps decouple the business logic from the presentation layer which in turn gives you the flexibility to make changes to a layer, without affecting the other. This also leads to effective testing and maintainability.
The implementation of this pattern is divided into three parts:
-          Model – Represents the domain specific data
-          View – UI Components responsible to display the Model data
-          Controller – Handles User Interactions/Events, manipulates and updates the model to reflect a change in the state of an application.
 
What is ASP.NET MVC?
ASP.NET MVC is a web development framework that embraces the MVC architecture. It is a part of the ASP.NET framework and provides an alternative way to develop ASP.NET Web applications.
Microsoft started working on the ASP.NET MVC framework in October 2007 and after a series of Previews and Beta Releases, ASP.NET MVC 1.0 was released on 17th March 2009. As of this writing, ASP.NET MVC 2 Preview 1 has been released
 
I find ASP.NET WebForms easier. When and Why should I Care about ASP.NET MVC?
Again, ASP.NET MVC is not introduced to replace WebForms. WebForms has been amazing in its own arena, but depending on your experiences with it and how far have you have exploited it’s usage in your applications, there are difference of opinions as far as its advantages and disadvantages are concerned.
Here are some points that will help you understand and embrace ASP.NET MVC.
ASP.NET MVC is for you if you –
-          care to build applications that are maintainable, testable and are ‘abreast’ with the other development methodologies, a couple of years from now.
 
-          emphasize on reducing complexity by enforcing ‘separation of concerns’ and introducing loose coupling. Tasks are separated and handled by separate components.
 
-          are tired of dealing with postback and viewstate issues
 
-          choose testability (Test Driven Development) over rapid application development(rad) where in rad, a single class is responsible for displaying output and responding to events. This behavior couples the layers tightly, making it difficult to test.
 
-          have a large team of developers and want to promote parallel development where there are separate teams working on the view, controller and model.
 
-          want to provide your application with multiple user interface. Since there is no or little dependency between different components, you can adopt a pluggable UI model in your application keeping the same business components.
 
-          are worried that your smart-client look-a-like, tightly coupled and stateful abstracted webform model is difficult to test and breaks frequently while maintaining application.
 
-          want a simple, seamless and maintainable AJAX experience like other platforms provide
 
-          want meaningful, RESTful URL’s
 
-          need to work on multiple platforms later. A shift from ASP.NET MVC to Ruby on Rails and other similar platforms is easier. It’s also a good option to consider for your career.
My advice to all you developers out there would be to go ahead and pick up this new technology, develop a sample MVC project and you will soon realize that you are following architectural best practices, are closer to the way web works and are using AJAX and JQuery efficiently to deliver jaw dropping UI experiences. A lot of our development time has gone in measuring the height and width in your apps – it’s now time to take a dive into the depth of it and see how things are done the right way – the web oriented way. After all, we will be trying a framework based on a pattern that has been used for over 30 years now! So the ‘it will work’ tests have been done for us.
 
 
Where can I download ASP.NET MVC from? Is it Free?
Yes, ASP.NET MVC is absolutely free. You can download ASP.NET MVC 1.0 from here
As of this writing, ASP.NET MVC 2 Preview 1 has been released which can be downloaded from here
 
 

Integrate NUnit with Visual Studio Express


NUnit Test Application

C# Project Template

Integrated tests with Visual Studio, including Visual C# Express version
Self contained NUnit console runner. Allow to write test fixtures and test, running from Visual Studio simply by pressing F5 (support test debugging), or Ctrl-F5 free run with results in console window. In case of test failure indicate by beep sound.

Contains essential NUnit modules to start test project. No external dependencies. Simply create new project, using NUnit Test Application template.


How to add shadows under C# forms in XP

protected override CreateParams CreateParams
{
    get
    {
        const int CS_DROPSHADOW = 0x20000;
        CreateParams param = base.CreateParams;
        param.ClassStyle += CS_DROPSHADOW;
        return param;
    }
}

Fast string replacing algorithm with C# in dotNET

/// <summary>
/// Implements fast string replacing algorithm for CS
/// </summary>
public static string ReplaceEx(string original, string pattern, string replacement, StringComparison comparisonType)
{
    if (original == null)
    {
        return null;
    }

    if (String.IsNullOrEmpty(pattern))
    {
        return original;
    }

    int lenPattern = pattern.Length;
    int idxPattern = -1;
    int idxLast = 0;

    StringBuilder result = new StringBuilder();

    while (true)
    {
        idxPattern = original.IndexOf(pattern, idxPattern + 1, comparisonType);

        if (idxPattern < 0)
        {
            result.Append(original, idxLast, original.Length - idxLast);

            break;
        }

        result.Append(original, idxLast, idxPattern - idxLast);
        result.Append(replacement);

        idxLast = idxPattern + lenPattern;
    }

    return result.ToString();
}

Unable to make the session state request to the session state

Dear all,
Due to the known problem of session variables getting lost if using InProc-server during frequent changes in development, I had to choose between SQL and ASP.NET State server, so I opted for the second. Initially, all fine, but after using it for a few days, I started to get this error:
 Server Error in '/cv2' Application.
Unable to make the session state request to the session state server. Please ensure that the ASP.NET State service is started and that the client and server ports are the same.  If the server is on a remote machine, please ensure that it accepts remote requests by checking the value of HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\aspnet_state\Parameters\AllowRemoteConnection.  If the server is on the local machine, and if the before mentioned registry value does not exist or is set to 0, then the state server connection string must use either 'localhost' or '127.0.0.1' as the server name.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: Unable to make the session state request to the session state server. Please ensure that the ASP.NET State service is started and that the client and server ports are the same.  If the server is on a remote machine, please ensure that it accepts remote requests by checking the value of HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\aspnet_state\Parameters\AllowRemoteConnection.  If the server is on the local machine, and if the before mentioned registry value does not exist or is set to 0, then the state server connection string must use either 'localhost' or '127.0.0.1' as the server name.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[HttpException (0x80004005): Unable to make the session state request to the session state server. Please ensure that the ASP.NET State service is started and that the client and server ports are the same.  If the server is on a remote machine, please ensure that it accepts remote requests by checking the value of HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\aspnet_state\Parameters\AllowRemoteConnection.  If the server is on the local machine, and if the before mentioned registry value does not exist or is set to 0, then the state server connection string must use either 'localhost' or '127.0.0.1' as the server name.]
   System.Web.SessionState.OutOfProcSessionStateStore.MakeRequest(StateProtocolVerb verb, String id, StateProtocolExclusive exclusiveAccess, Int32 extraFlags, Int32 timeout, Int32 lockCookie, Byte[] buf, Int32 cb, Int32 networkTimeout, SessionNDMakeRequestResults& results) +1565
   System.Web.SessionState.OutOfProcSessionStateStore.SetAndReleaseItemExclusive(HttpContext context, String id, SessionStateStoreData item, Object lockId, Boolean newItem) +192
   System.Web.SessionState.SessionStateModule.OnReleaseState(Object source, EventArgs eventArgs) +355
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +92
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64

Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42

 Meanwhile the event log on the server (W2K2003) always logged this error (rI've emoved some details from it):
 Event code: 3009
Event message: Unable to make the session state request to the session state server. Details: last phase='Reading response from the state server', error code=0x8007274C, size of outgoing data=45999
Event time: 9/29/2006 11:40:17 AM
Event time (UTC): 9/29/2006 3:40:17 AM
Event ID: 0ec55d45b61f457d95d3d3c256d7cab7
Event sequence: 4
Event occurrence: 1
Event detail code: 50016

Application information:
    Application domain: /LM/W3SVC/1/Root/cv2-4-128039748000937500
    Trust level: Full
    Application Virtual Path: **********
    Application Path: **********
    Machine name: **********

Process information:
    Process ID: 720
    Process name: w3wp.exe
    Account name: NT AUTHORITY\NETWORK SERVICE

Exception information:
    Exception type: HttpException
    Exception message: Unable to make the session state request to the session state server. Please ensure that the ASP.NET State service is started and that the client and server ports are the same.  If the server is on a remote machine, please ensure that it accepts remote requests by checking the value of HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\aspnet_state\Parameters\AllowRemoteConnection.  If the server is on the local machine, and if the before mentioned registry value does not exist or is set to 0, then the state server connection string must use either 'localhost' or '127.0.0.1' as the server name.

Request information:
    Request URL: **********
    Request path: **********
    User host address: 192.168.0.181
    User: **********
    Is authenticated: True
    Authentication Type: Forms

Thread information:
    Thread ID: 1
    Is impersonating: False
    Stack trace:


Custom event details:
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
"Of course" the link http://go.microsoft.com/fwlink/events.asp did not help, "we're sorry" page showed up.
I also saw a lot of abandoned posts asking about lost session state on this forum when searching. Some suggested increasing the time out, which I believe had nothing to do with the issue.
The state service configuration worked fine when running on the development machine, and I was 100% sure the asp.net state service had the correct and same port numbers.
I also tried the latest VS 2005 SP1 beta on dev. machine and server but no effect on the issue (although it solved some other bugs).
I also tried setting the ASP.NET state server registry key to accept remote connections (flag to 1 instead of 0), but no effect.
It turned out this KB solved the issue:
http://support.microsoft.com/kb/919080/en-us?spid=8940&sid=global
 Interestingly enough, I have not uninstalled the .NET 1.1 framework, and the server is a plain 32-bit platform, so the title was pretty misleading.
So I "adapted" the hotfix to:
1. change dir to: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
2. type aspnet_regiis -i -enable|
3. Machine chews command for about 1 minute or so
4. Done! When I click "log in" button on the start page with correct credentials, the session state is working fine again.
And actually, that's all!
Apparently, the ASP.NET 2.0 framework with IIS was corrupted, but I can't recall any particular action that specifically broke it, except that I did a system restart, which may have triggered some pending action initiated long ago.
Would be interesting to know if this solves the problem for others who have the same issue.