If you want to perform validation on the fields of a DetailsView at run time you can hook into the ItemInserting and ItemUpdating events as shown below. By Setting e.Cancel to true, it is possible to abort the insert/update action, and thus force the user to return to the form. /// <summary> /// Check if […]
Month: February 2020
Determine response time from an ip ping
‘ — ping the ip adress in the string s_ipaddr, and get ‘ the response time in the int32 n_response ‘ imports system.net.networkinformation Dim ping As New System.Net.NetworkInformation.Ping Dim reply As System.Net.NetworkInformation.PingReply reply = ping.Send(s_ipaddr) If reply.Status = IPStatus.Success Then ‘ — handle reachable here MsgBox(“ping time ” & reply.RoundtripTime) Else ‘ — handle non […]
Running a console command and capturing the output
This code sample demonstrates how to execute a console command and capture the output. The VB versions takes the “short route” using the shell command, while the C# version takes the approach of starting a process object, which gives you greater control over the proccess and enables you to pipe the outpout directly into the […]
Enumerating the active forms within an application
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}”, […]
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 […]