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

Display exactly 2 digits after decimal without Rounding on SQL Server

let say, we had a value 7.35642132 on sql query return, then we want to display it only exactly 2 digits after decimal without Rounding, here is the way :

to get only two digits after decimal for a value 7.35642132
Select LTRIM(RTRIM(STR(7.35642132,10,2)))

the results is 7.35

Enable content expiration under IIS 7

In IIS6, it was with the website properties –> HTTP Headers. Here in IIS7, you can do this on the “HTTP Response Headers” feature on the website.

  • Select the website in the Connections pane.
  • Double click on the “HTTP Response Headers” feature in the features pane
  • In the action pane, click on the “Set Common Headers…”

image

  • You will see the following popup

image

Now, you know what to select. You should enable the HTTP Keep-Alive on this popup only.

 

Source : http://blogs.msdn.com/b/rakkimk/archive/2007/07/10/iis7-how-to-enable-content-expiration.aspx

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

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”

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.

Add RunAs to Explorer Context Menu in Vista and Server 2008

As a Domain Admin for a small or large corporation, it’s NEVER a good idea to login as the Domain Admin (or other privileged user) to read email or surf the Internet.  After all, if you pickup a nasty bug/virus, from Outlook or Internet Explorer your logged in credentials will have the ability to spread the virus to every system in the company…  Not a good thing!

 

That’s where the RunAs command (XP and Server 2003) came in handy over the years.  You could login as a non-privileged user but if you needed to do something which required Admin rights, you could hold down Shift and Right Click on the application in Windows Explorer and start the application using your Admin credentials.

 

With the release of Windows Vista and Server 2008, this all changed.  True, you could still use the RunAs.exe from the command line however, if you wanted to do it with Windows Explorer.  Fortunately Mark Russinovich has written a new tool called  which adds the RunAs feature to Windows Explorer.

 

Follow the below Step by Step to get it rolling on your box:

 

 

Add Run As Different User to Windows Explorer Context Menu for Vista and Server 2008

1) After you download ShellRunAs from here, copy it to your WindowsSystem32 folder,

 

2) Open a command line and Runshellrunas /reg

Add Run As Different User to Windows Explorer Context Menu for Vista and Server 2008 :: groovyPost.com

 

3) Click OK to confirm Install completed

Add Run As Different User to Windows Explorer Context Menu for Vista and Server 2008 :: groovyPost.com

 

To test, hold down SHIFT and Right-Click on an application.  You should now see the Run as different user in your context menu.

 

Before:

Add Run As Different User to Windows Explorer Context Menu for Vista and Server 2008 :: groovyPost.com

 

After:

Add Run As Different User to Windows Explorer Context Menu for Vista and Server 2008 :: groovyPost.com