Wednesday, November 28, 2007
When you want to debug your own written Windows Service, you have to install the service on your local machine and attach the Visual Studio 2005 debugger to the process.
There is an easy way to start (and test) the windows service within Visual Studio 2005.
1) Add a public method to your windows service class to invoke the protected OnStart :
public void OnStart()
{
this.OnStart(null);
}
2) Add a new class to your windows service project
public class Entry
{
static void Main()
{
#if DEBUG
MediationService myService = new MediationService();
myService.OnStart();
System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
#endif
}
}
3) Set the Startup object in the properties window of your project to the new Entry class
4) Set your breakpoint wherever you want and start debugging directly from Visual Studio 2005
Wednesday, May 16, 2007
Sometimes in your web application you will have a link to a file on the server. Problems occur when the user clicks on the link and opens the file in the browser. If the user wants to save the file he will get an error. To force the user to dowload the file you can disable the left click but keep right clicking enabled.
To make the script accessible on all web pages I declared the script in the default.aspx file
<head id="Head" runat="server">
<script language="javascript">
function noLeftClick()
{
if (event.button==1)
{
alert('Please use the rightclick \"Save Target As\" Command to Download')
}
}
</script>
</head>
In the html content you have to add the call to the javascript :
<a href=http://server.filename.xls onMouseOver='document.onmousedown=noLeftClick' onMouseOut='document.onmousedown=null'>filename</a>
As you see, you can right click and save the target as, but you can not directly click on it.
Sunday, March 18, 2007
In ASP.NET 2.0 there is a simple new property in the System.Web.UI.Page object called 'MaintainScrollPositionOnPostback'.
When you set this property to 'true', javascript will be inserted in your rendered page that maintains the scroll position in the browser window for all postbacks. Those of us who have done this manually, know that this is not rocket science to achieve, but its sooo nice to be able to set a single property to just 'make it happen'. You can alse set this property in the web.config file to use it on all pages.
<pages validateRequest="false" enableViewStateMac="true" enableEventValidation="false" maintainScrollPositionOnPostBack="true">
I used this property in several DotNetNuke (4.x.x) projects but ran into a major problem when logging off. I always get the error 'The maintainScrollPositionOnPostback property can not be set without an html form'. The standard home page will not be shown :-(
When logging off, dotnetnuke will redirect to a default logoff page located under Admin\Security\logoff.aspx
This is an empty page with only the Page_Load event used. In this event, the user will be logged off from the cookie authentication system and the user will be redirected to the default home page.
To solve the error you only have to set the property to false in the page directive
<%@ Page MaintainScrollPositionOnPostback="false" language="vb" ...
Friday, February 02, 2007
Why are relational databases the most popular? Differentiate between primary and foreign keys. Design relational database tables and learn about normalization rules and de-normalization.
Free video on LearnVisualStudio.Net : Download This Free Video
Differentiate between database files and SQL Server processes. Explore scenarios for connecting to SQL Server Express databases, enabling and disabling user instances, login permissions, and other security precautions.
Free video on LearnVisualStudio.Net : Download This Free Video