my scenario is, if user put focus on text in WebDropDown, then text should be highlighted and when he click on Backspace button on keyboard, then text value should disappear.
i am working in .NET and i want to implement this functionaliy in Javascript or JQuery.
How to do it ??
Hi snohig_07,
In order to highlight the text in the WebDropDown's input, you can handle the Focus client-side event and use the following javascript code:
function WebDropDown1_Focus(sender, eventArgs) { sender._elements["Input"].selectionStart = 0; sender._elements["Input"].selectionEnd = sender._elements["Input"].value.length;}
You can find more information regarding the WebDropDown in our documentation at:
http://help.infragistics.com/NetAdvantage/ASPNET/2011.1/CLR4.0/?page=Web_WebDropDown.html
Please feel free to contact me if you have any questions.
Best Regards,
Petar IvanovDeveloper Support EngineerInfragistics, Inc.http://ko.infragistics.com/support
Hi Petar,
i tried but its not happening. Please find the code below
----JS code----
<script type="text/javascript">
function wddFocus_Focus(sender, eventArgs)
{
sender._elements["Input"].selectionStart = 0;
sender._elements["Input"].selectionEnd = sender._elements["Input"].value.length;
}
</script>
----.ASPX code----
<igWebDropDown:WebDropDown ID="wddFocus" runat="server"
Width="200px"
TextField="FirstName" ValueField="Id">
<ClientEvents Focus="wddFocus_Focus" />
<DropDownItemBinding TextField="FirstName" ValueField="FirstName" />
</igWebDropDown:WebDropDown>
----C# code----
DataSet SongDS = new DataSet();
protected void Page_Load(object sender, EventArgs e)
DataTable songTable = SongDS.Tables.Add();
//-- Add columns to the data table
songTable.Columns.Add("FirstName", typeof(string));
//-- Add rows to the data table
songTable.Rows.Add("Diary of Jane");
songTable.Rows.Add("Pain");
songTable.Rows.Add("Fake It");
songTable.Rows.Add("Paralyzer");
songTable.Rows.Add("Citizen Soldier");
this.wddFocus.DataSource = SongDS;
this.wddFocus.DataBind();