Thursday, November 25, 2010

Adding ListItem using JavaScript in ASP.NET

Sometimes we may need to add a listitem in a dropdownlist in client side using JavaScript. To add it we can use the following code. You can execute the cs code by any method or button click event etc.

In the test.aspx page





In the test.aspx.cs file
string jsCmdAddListItem = "var ddlTest = document.getElementById('" + drpTest.ClientID + "');" +
" var newListItem = document.createElement('OPTION');" +
" newListItem.text='ADDED_JS ITEM THREE';" +
" newListItem.value='3';" +
" ddlTest.appendChild(newListItem);";
if (!ClientScript.IsClientScriptBlockRegistered("ClientScript"))
{
ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "ClientScript", jsCmdAddListItem, true);
}

Note that, the server side code knows nothing about this additional item. To let server side code know about this additional item you have to add a listitem as well to the DropDownList, for example:
ListItem itemThree = new ListItem("ADDED_CS ITEM THREE", "3");
drpTest.Items.Add(itemThree);

I'm afraid somebody will not understand it clearly, please leave a comment, I'll try to reply as early as possible.

Tuesday, November 23, 2010

How to install a DLL file in Windows?

  1. Uncompress the DLL downloaded file from DLL-Downloads.com to your system32 folder within the Windows folder. [c:\WINDOWS\system32]
  2. Click on the Start button, then click the Run... option
  3. In the "Open" line, type the following (without quotes) "regsvr32 filename.dll" (replace filename.dll with the actual filename of the file you downloaded), then click the "OK" button.


  4. How to Install a DLL file?

  5. If the installation was successful, you should see a message saying that your file was successfully installed/uninstalled.

    How to install a DLL file? - Use regsvr32 installation command

Thursday, November 4, 2010

How To Select Default Internet Connection From Multiple Connections

There are times when we have multiple internet connections and multiple gateways to browse the internet. In this situation, we don’t know which internet connection is being used right now. All this can be seen with a built-in command in Windows. Issue the following command and you’ll get the full routing table of Windows:

C:>route print         [For Vista/7         C:\route print -4]

How To Select Default Internet Connection From Multiple Connections

Look for the row which specifies Network destination as 0.0.0.0 and netmask as 0.0.0.0. In this row, you’ll find a default gateway section which will be your gateway. If you have multiple internet connections, you will find multiple entries with the above properties. Now that you have seen the gateways, note down the Metric for each gateway.

The default gateway that is being used for the internet connection is the one with the smallest metric value. If you want to make another internet connection default, you have to change its metric to the lowest.

There is no easy way to edit the routing table and lower the metric value for the default gateway of your choice. NetRouteView is one utility from Nirsoft which can be used to edit these values.

How To Select Default Internet Connection From Multiple Connections

Download NetRouteView from the following link and start it. First select the route you want to make default and then selct File –> Modify Selected Route or simply press Ctrl-M. Now make the Metric value the lowest from all the other default routes we identified previously.

Download NetRouteView