Disable AutoComplete in Asp.NET

Most Browsers have a feature called AutoComplete which saves information that has previously been inputted like web addresses and form data. But sometimes, you may want to disable this feature for inputs like credit card information.

ASP.NET has the ability to override the user’s choice with the autocomplete attribute by setting it to off. This can be added to a form tag or any TextBox control and can be done using one of the following two properties:

  • AutoComplete=”Off”
  • AutoCompleteType=”Disabled”

View some examples after the break…

Continue reading

Source Control – AnkhSVN

ankhsvn

At work, we started using source control a year ago and after several packages we chose to use VisualSVN and was doing a good job until recently we started to find some problems. When trying to commit some changes, it was always asking to ‘Clean up’ the solution. Then obviously I would click on Clean up and upon doing so, another error was loading…. guess what… it’s asks me to Clean Up the solution…. and it’s never ending. It got on my nerves and today I started searching for another Source Control.

I found the AnkhSvn (don’t know how to spell it), checked some reviews and gave it a go! Till now it seems to be fantastic. It incorporates directly into Visual Studio’s Source Control (not like VisualSVN), it has a pending changes window (at the bottom of visual studio) from where you can write a message and commit with a simple step (not like VisualSVN where you have to right click the file, and choose commit… and if you’re lucky, it works)…. and the greatest feature of all is that it’s free!! For VisualSVN you’d have to pay around $50 for each user.

To use AnkhSVN for yourself, you just install a copy from here

To use AnkhSVN between multiple users, you need to install a copy on every user’s machine by downloading from here, then install VisualSVN Server (here) on the computer where you’ll store the Source Control files. Click here for a simple ‘How To’ to start using AnkhSVN. BTW… VisualSVN Server is also free so you’ll get the best of both worlds, for Free!

Till now i’m liking what i’m seeing… if I’ll find any problems… I’ll let you know. Happy controlling!! 🙂

For more info on:

For info on why you need to use a source control and back up, click here

Crystal Reports Problem

The following error loaded today when trying to output a crystal report from asp.Net:

Logon failed. Details: crdb_adoplus : Object reference not set to an instance of an object. Error in Filename.rpt: Unable to connect: incorrect log on parameters.

The problem was that I didn’t set the report’s DataSource. Next is the code that worked:

 

 

 

ReportDocument report = new ReportDocument();

 

 

report.Load(Server.MapPath(“Reports\Label.rpt”));

report.SetDataSource(dset);

report.ExportToDisk(ExportFormatType.PortableDocFormat, full_path);

report.Clone();

report.Dispose();

Hope this helps someone!! 🙂

 

 

 

 

Disable Triggers

Last time, I had some calculation problems in one of my tables, and I needed to make a simple batch Update on the table but the following error was loading…

Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.

After several trial and errors, I finally found the problem: it was that I had a trigger on the table and it didn’t let me batch Update. After googling i found that you can disable any trigger using the following code in you SQL Statement:

DISABLE TRIGGER triggername ON tablename

add batch update or batch insert command;

ENABLE TRIGGER triggername ON tablename

And now the batch Update worked flawlessly. Hope this works for you too.

(PS. It’s important to insert a semi-colon (;) after your update or insert command, as it would give an error and wouldn’t re-enable the Trigger.)

ContextSwitchDeadlock was detected

Last week i was debugging an application and after while the following exception was being loaded:

ContextSwitchDeadlock was detected
Message: The CLR has been unable to transition from COM context 0x1b2938 to
COM context 0x1b2aa8 for 60 seconds. The thread that owns the destination
context/apartment is most likely either doing a non pumping wait or
processing a very long running operation without pumping Windows messages.
This situation generally has a negative performance impact and may even lead
to the application becoming non responsive or memory usage accumulating
continually over time. To avoid this problem, all single threaded apartment
(STA) threads should use pumping wait primitives (such as
CoWaitForMultipleHandles) and routinely pump messages during long running
operations.

After googling, i found that this error happens when an operation is performing lenghty operations not allowing the message queue to pump. Continue reading

There is already an open DataReader…

Sometimes, when I try to get data from the SQL Server the following exception is loaded:

“There is already an open DataReader associated with this Command which must be closed first.”

This occurs when you have multiple DataReaders open concurrently on the same connection, ie you call SqlCommand.ExecuteReader but don’t close the SqlDataReader returned by this method before calling it again (either on the same command or another command on the same connection).

This is due to a change in the default setting for MARs (Multiple Active Result Sets).  By default, It used to be set as True but it was changed and was set to False by default post RC1.

So to remove this exception, you just need to change the following: Continue reading

Visual Studio 2005 – Crashes Randomly

Visual Studio 2005 

 

Last week i was using Visual Studio 2005 and all of a sudden it started to crash. Everytime i tried to open VS after 1 or 2 minutes it would crash. I checked the event log and the following error appeared:

Faulting application devenv.exe, version 8.0.50727.762, time stamp 0x45716759, faulting module craxddrt.dll_unloaded, version 0.0.0.0,
time stamp 0x43068582, exception code 0xc0000005, fault offset 0x0d26e30f, process id 0x1180, application start time 0x01c75cae13960a41.

After googling the problem, i found the following solution. The problem was that when opening my solution, by default it opened the last crystal report that i was working on. This seemed to start some crystal report ActiveX thing that didn’t work on Vista.

Sometimes it would take 2 minutes and sometimes 5 minutes, but it would always crash, even if i closed the report straight away.  The only way to stop this problem was to load up VS, close the report immediately and safely close VS before it got a chance to crash! The next time it opens, there is no crystal report and the ActiveX control never loads.

So the next time you save the solution and close visual studio be sure to close all Crystal Reports window 🙂

Happy Programming.

Reference: http://tim.mackey.ie/FIXVS2005CrashesRandomlyWhenUsingCrystalReports.aspx

Multiple Sitemaps

Globalization

A problem that i found lately was when i needed to have multiple sitemaps. Why? I needed different menus for different parts of the website. Normally, the sitemap must be found at the root of the website. After searching, I found this solution which is very easy to implement… Next are the steps:

1. In web.config, you can add multiple site map providers, and set the siteMapFile property. Continue reading