hi,
I have an Grid with {txt_prodname,txt_type,txt_pages,txt_copies} //here txt_type is my Dropdown list.
Now my requirement is
1. While
focus on my dropdown i need to select an default value of "SelectedIndex=1" not "0".
hence i use js as
function selectOneside(val) {
var Dval = val.selectedIndex;
if (Dval == "0") {
val.selectedIndex=1;
}
}
My dropdown inside grid is like..
<ItemTemplate>
<asp:DropDownList ID="txt_type" runat="server" AutoPostBack="true" onfocus="selectOneside(this);" onselectedindexchanged="txt_type_SelectedIndexChanged">
<asp:ListItem Value="0">--Select Type--</asp:ListItem>
<asp:ListItem Value="1">One Side</asp:ListItem>
<asp:ListItem Value="2">Diff Front & Back</asp:ListItem>
<asp:ListItem Value="3">Same Front & Back</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
Till that works fine,
but while i go to the next row again its changed, without enter txt_prodname
Hence i use onblur event for my txt_prodname inside grid as...
<ItemTemplate>
<asp:TextBox ID="txt_prodname" runat="server" Width="110px" OnTextChanged="txt_prodname_TextChanged" CssClass="autocompleteTXT"></asp:TextBox>
</ItemTemplate>
My js is...
function prodname(txtval,ddlval) {
var Dval = txtval.value;
if (Dval == "") {
ddlval.selectedIndex = 0;
txtval.focus();
}
}
I bind this blur event from my server side as
txtprodname.Attributes.Add("onblur", "javascript : prodname(" + txtprodname.ClientID + "," + txttype.ClientID + ")");
As i mentioned in js(prodname) i got focus to my textbox but...
Problem is my dropdown not getback to "SelectedIndex=0" when txt_prodname is empty
focus and Blur Play in my life :(
Please help me out...