In writing “Notes from the field” allows Baron Software to list quick fixes or observations from the programming world.
Anchors away!
Using PHP and HTML it can remember the window position as to where the user left off. Without the need of elaborate coding using an “Anchor” can solve the issue.
<a id=”anchor-name”>The name where you want to jump</a>
Anchors can be used when pages have considerable amounts of text. You would typically make an index at the top of the page linking to the anchors that have been added to key places in the text that follows.
When displaying a list of records within a PHP while loop you can place the record ID within the data. The code listed below has the anchor next to the hyperlink.
<?php
while($row=mysqli_fetch_assoc($result)){
?>
<tr>
<td align="center" bgcolor="#FFFFFF">
<?php echo $row['County']; ?>
</td>
<td align="center" bgcolor="#FFFFFF">
<a href="editProperties.php?id=<?php echo $row['PropertyID']; ?>&ep=Y">
<?php echo $row['Premises']; ?></a>
<a id="<?php echo $row['PropertyID']; ?>" ></a>
</td>
...
The PHP page “EditProperties.php” has the return anchor with the hash tag ‘#’. This example stores the ID in a session variable upon the posting or the back button.
header("location:Properties.php#$_SESSION[PID]");
Using a few lines of code can help the end user in flipping between pages without losing their place.
What if you get “A generic error occurred in GDI+”
This is an error that occurs when playing with images and bitmaps using Visual Studio VB.NET or C#.
House cleaning is the key phrase. Creating images using bitmap or other components you must dispose of them when done.
The error message is not friendly and doesn’t really tell you much but keeping a bitmap image around could create access issues. The application may indicate that the image is in use.
Legacy applications
Good old Visual Basic 6 applications are still out there working in the 32 bit world. Now that Windows 10 has taken over the ability of doing simple tasks get harder.
One problem is printing the PCL files directly to the printer, not losing the escape characters but correctly converting them. There is one free application, RawFileToPrinter is available.
The syntax is straight forward.
RawFileToPrinter filename.ext “\\SERVER\PrinterName”
You can use the Shell command or Process.Start.
Process.Start
does give more options on controlling the process. You can specify much more options using a ProcessStartInfo object as a parameter.
Shell
only returns the process id which you would have to look up in the list of running processes whereas Process.Start
return a Process
object which you can use to check for its state etc.
Also note that Shell
resides in the Microsoft.VisualBasic
namespace which largely contains deprecated methods for legacy purposes. You should try to avoid using anything in here in favor of an alternative in another namespace.
You must be logged in to post a comment.