Set Selected Value for DropdownList on Clientside using Javascript

Sometimes we need show the dropdownlist control with some selected value after some activity ( without server postback ) on the web page.
we can do that on clientside with the help of javascript.

function SetSelectedIndex(dropdownlist,sVal)
{
var a = document.getElementById(dropdownlist);

for(i=0;i<a.length;i++)
{
if(a.options[i].value == sVal)
{
a.selectedIndex = i;
}

}

}

Call the above function on your required event i.e. onclick,onblur etc… from code behind.

SetSelectedIndex(‘<%=ddldropdownlistName.ClientID %>’,”ValueToBeSelected”)