Passing variable from code behind to HTML tag in ASP.NET

Some how in some case, we want to directly passing variable that we already declare in ASP.NET with code behind to the HTML tag, like <input type = “TEXT”> tag in HTML, we can do that just with the simple code, here is the way:

Declare test as a property (at the class level) instead of a local variable, then refer to it as you currently do in your markup (aspx).

VB.NET 10 (automatic properties):

Protected Property test As String = "Test" 

---------------------------------------------

Pre-VB.NET 10 (no support for automatic properties)

Private _test As String
Protected Property Test As String
Get
     Return _test
End Get
Set(value As String)
     _test = value
End Set
End Property

——————————————————–

place that variable in HTML tag that you want to place, such as :

<input type=”TEXT” name=”SomeThing” size=”50″ maxlength=”250″ value = “<%= test %>”>

 

that’s all, hope this helpful

Run CGI program under IIS 7.0

Looking around I didn’t find a good documentation on how to get good old CGI’s running on IIS 7 or 7.5. Here is a quick walkthrough:

1. Let’s write a quick CGI:
Take the following code and save it as simplecgi.cs in the directory c:\inetpub\wwwroot\cgi

using System;
using System.Collections;

class SimpleCGI
{
    static void Main(string[] args)
    {
        Console.WriteLine("\r\n\r\n");
        Console.WriteLine("<h1>Environment Variables</h1>");
        foreach (DictionaryEntry var in Environment.GetEnvironmentVariables())
            Console.WriteLine("<hr><b>{0}</b>: {1}", var.Key, var.Value);
    }
}

2. Change into the C:\inetpub\wwwroot\cgi directory and compile the source by using the following command-line:

%windir%\Microsoft.NET\Framework\v2.0.50727\csc.exe SimpleCGI.cs

Read more of this post

Excel 2003 Add-in: XML Tools Add-in

Instructions

To install the add-in, complete the following steps:

    1. Start Excel.
    2. On the Tools menu, click Add-Ins.
    3. Click the Browse button and navigate to the .xla file.
    4. Select it and then click OK.
    5. Click Yes to any file copy or overwrite prompts.

 

How to install Add-in in MS Excel 2007

1. Click the ball office logo at the top-left of the program
2. Click button “Excel Option”

3. Select item “Add-Ins”
4. Select “Excel Add-Ins” in Manage list box and click button “Go…”

5. Tick the add-ins that you want and click button “OK”

Convert a Excel workbook to an xml file

This post is a bit off topic for this blog but I’ll post it anyway as a reminder for myself and hopefully to help others who want to do the same. At a client someone had to convert a very simple, plain, flat text excel 2007 workbook to an xml file format.

I have made an example to let you see how to do this. Below you see the workbook that has to be converted to xml.

exc_workbook1

I thought that just saving the file with “save as” to xml format would do it but I thought wrong. I got an error that there were no XML mappings found in the workbook. For Excel 2007 you need a add-in that is called OfficeExcel2003XMLToolsAddin.exe and which can be downloaded here. On the download page you can also read how to install and open the add-in in Excel 2007.

Read more: http://www.information-worker.nl/2010/04/19/howto-convert-a-excel-workbook-to-an-xml-file

Unlocking files that are in use

Sometimes you cannot delete or rename a file that is currently in use. You might receive an access violation error, or simply a message telling you that your action could not be completed because the file is open in another program.

image

You may have already come across the Unlocker freeware tool that lets you “unlock” files that are in use by some application.

Here is another way (let’s call it the ‘techie’ way) to unlock files that are in use. It makes use of the Process Explorer tool from Windows SysInternals.

  • Download the Process Explorer tool. Execute procexp.exe
  • Choose Find Find Handle or DLL option

image

  • Type the name of the file you want to unlock and hit Search.

image

  • The process EXE locking the file and the path to the file are listed. Double click on the result.

image

  • The file handle will be highlighted. Right-click on it and choose Close Handle.

Your file is now unlocked and can now be deleted, moved or renamed.

A little disclaimer here, closing handles might cause data inconsistency, loss and/or other undesirable effects. Make sure you understand what you’re doing before you do it.

Killing Processes from a Visual Basic Application

This article provides a simple example of how to use the System.Diagnostics.Process library to display a list of running processes, and to select and kill processes by their process name and ID. It would not be a major trick to display additional information about the process using the same library or to kill processes by their ID or name alone rather than their name and ID but in this example, process names and IDs are used for display purposes and the purpose of killing a running process.

image001.png

Figure 1: Listing and Killing Processes by Process Name and ID

Getting Started

There is a single solution included with this download, the solution contains a Win Forms project called “ProcessKillerVB”; this project contains one form (Form1.vb) and all of the code required to display and kill processes is contained within that single form class. If you open the attached project into Visual Studio 2008; you should see the following in the solution explorer:

image002.png

Figure 2: Solution Explorer

Code: The Main Form

The main form contains all of the user interface elements necessary to display and update the list of currently running processes found on the user’s machine. It also contains a button handler which will kill a process by the process name. You can also kill a process by its ID but in terms of readability, if the user is selecting the process, the process name is going to make a lot more sense to them than will the process ID.

Read more of this post