VB.NET Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ‘ — Build a list of all active forms, and display it to the user Dim activeforms As String = String.Empty For Each item As Form In Application.OpenForms activeforms = String.Format(“{0}{1}{2}”, activeforms, item.Name, vbCrLf) Next MsgBox(String.Format(“The names of the active forms are:{0}”, […]
Author: bobnoordam
Sending email with an inline image
While you will usualy link images to a static location, there are situations where it can be very practical to include the actual image in the message and send it inline. This code snippet is a demonstration of the minimal code required to send an email message with an inline image using C#. using System.Net.Mail; […]
Windows 8.1 Network location changing
How a simple thing like changing a network connection between private and public has become a challenge of itsself. It’s saddening realy. Once you run into a mobile network you own and control and have no way left to change its location type through the gui because Windows determines some options should just not show […]
Breaking the windows update reboot loop
Every now and then, especialy with new installations Windows server 2012 and 2012 R2 get stuck in a reboot loop. After initial installation a massive batch of patches is retrieved and installed. On reboot, a failure message is displayed and windows tries to undo the updates. After a lengthy period of time the server reboots, […]
Changing a field into a date editor
The following example shows the markup for a DATETIME field from a database bound to a ASP.NET DetailsView before and after converting it into a templatefield and binding it to the ASPxDateEdit control. Default markup after converting to a template field: <asp:TemplateField HeaderText=”GebDat” SortExpression=”hrGebDat”> <EditItemTemplate> <asp:TextBox ID=”TextBox2″ runat=”server” Text='<%# Bind(“hrGebDat”) %>’></asp:TextBox> </EditItemTemplate> <InsertItemTemplate> <asp:TextBox ID=”TextBox2″ […]
Moving focus when right-clicking on a datagridview
The .NET framework integrates a context menu that easily can be bound to any datagridview. By default, this context menu operates on the “selected row”. But what if you’re user right-clicks somewhere else on the grid ? He will still get an context menu that operates on the selected row, even tho it appears on […]
Handling the gridview’s pageindex from code
When binding a custom dataset to a gridview and enabling paging, you will be greeted by an error stating that the griview started the PageIndexChanging event, and that the event wasn’t handled. This occurs because the built in sqldatasource will handle paging for you by caching the dataset, and by binding your own dataset you […]
Maintaining vertical scroll position on an ASP.NET GridView across postbacks
Our mission Here is what we want to archieve with a standard ASP.NET gridview; We want scroll bars to scroll vertical in a potential long list When a row is selected in the gridview, we want to maintain the scroll position in gridview. (de default behaviour would be for the grid to jump back up […]
Securing session cookies in asp.net
Securing session cookies by itsself is very straightforward. By adding the following markup to the system.web section in web.config your session cookies will no longer function without https. <httpCookies requireSSL=”true” /> However, this will give you a new problem if you run in a test environment or debug session without https. Since the cookie will […]
MVC and Linq2Sql – Adding validation
MVC supports a lot of ‘good practice’ such as dependency injection, unit testing and mocking. These things all have their place, but for some small ad-hoc coding all of that isnt’s needed. Additionaly, people crossing over to MVC get confronted in most books and documentation with a ton of good advice that at best obfuscates […]