DropDownList width
-
Hello I have a dropdownlist in edititemtemplate of the gridview. However items are long so the dropdownlist becomes too wide. What I would like to do is to have dropdownlist which is small when it is collapsed and becomes wide when the items are visible. Is it possible? If I make its widht fixed then the items are cut when they are displayed. I would like for the dropdown to become wider. Thank you.
Giorgi Dalakishvili #region signature My Articles Asynchronous Registry Notification Using Strongly-typed WMI Classes in .NET [^] My blog #endregion
-
Hello I have a dropdownlist in edititemtemplate of the gridview. However items are long so the dropdownlist becomes too wide. What I would like to do is to have dropdownlist which is small when it is collapsed and becomes wide when the items are visible. Is it possible? If I make its widht fixed then the items are cut when they are displayed. I would like for the dropdown to become wider. Thank you.
Giorgi Dalakishvili #region signature My Articles Asynchronous Registry Notification Using Strongly-typed WMI Classes in .NET [^] My blog #endregion
you can set the width dynamically using Javascript
function dynamicWidth(evt,conversionFactor){
var selection = document.getElementById('test');
if (!selection.minmax){
selection.minmax=[parseInt(selection.style.width),0];
for (var i=0; i<selection.options.length;i++){
if (selection[i].text.length>selection.minmax[1]){
selection.minmax[1] = selection[i].text.length*conversionFactor;
}
}
}
selection.style.width = (evt?selection.minmax[1]:selection.minmax[0]) +'px';
}Option one
Option two which is long
Option three which is longer
Option four which is even more longMake your adjustment to render the control html in this manner... :rose::rose:
Abhishek Sur
-
you can set the width dynamically using Javascript
function dynamicWidth(evt,conversionFactor){
var selection = document.getElementById('test');
if (!selection.minmax){
selection.minmax=[parseInt(selection.style.width),0];
for (var i=0; i<selection.options.length;i++){
if (selection[i].text.length>selection.minmax[1]){
selection.minmax[1] = selection[i].text.length*conversionFactor;
}
}
}
selection.style.width = (evt?selection.minmax[1]:selection.minmax[0]) +'px';
}Option one
Option two which is long
Option three which is longer
Option four which is even more longMake your adjustment to render the control html in this manner... :rose::rose:
Abhishek Sur
I have a dropdowlist, not select. I not that the resulting HTML will be select but how can I apply your solution to dropdownlist? And the dropdownlist is in a usercontrol.
Giorgi Dalakishvili #region signature My Articles Asynchronous Registry Notification Using Strongly-typed WMI Classes in .NET [^] My blog #endregion
-
I have a dropdowlist, not select. I not that the resulting HTML will be select but how can I apply your solution to dropdownlist? And the dropdownlist is in a usercontrol.
Giorgi Dalakishvili #region signature My Articles Asynchronous Registry Notification Using Strongly-typed WMI Classes in .NET [^] My blog #endregion
use Attributes.Add["onclick", to invoke your function in client end. Well even if the dropdown is inside the user control, in browser it always renders one select. So get your select control from dropdown.clientID and invoke the function. you can use Server tag inside the javascript function to be replaced with client id. I think you can do that .. If you still unable to do so, I will send you one code for that then. :rose::rose:
Abhishek Sur