I try to get decorated DropDownList value after change.
I'm using jQuery to add event like this
var select = $('#<%= ddlControl.ClinetID %>');
select.change(function() {
alert($(this).val());
});
event is trigered correctly, but value is always 0. I did also inspect <select> in DOM inspector, and there is also always value = 0.
So, how to get this value if it's not changing?
Gr,
Pawel
13 Answers, 1 is accepted
Here is a small sample that shows how to achieve this:
<head id="Head1" runat="server"> |
<title></title> |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script> |
</head> |
<body> |
<form id="form1" runat="server"> |
<telerik:RadScriptManager ID="RadScriptManager1" runat="server" /> |
<telerik:RadFormDecorator ID="FormDec1" runat="server" DecoratedControls="All" /> |
<asp:DropDownList ID="ddlControl" runat="server"> |
<asp:ListItem Value="1"></asp:ListItem> |
<asp:ListItem Value="2"></asp:ListItem> |
<asp:ListItem Value="3"></asp:ListItem> |
<asp:ListItem Value="4"></asp:ListItem> |
</asp:DropDownList> |
<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server"> |
<script type="text/javascript"> |
var select = $('#<%= ddlControl.ClientID %>'); |
select.change(function() |
{ |
alert($(this).val()); |
}); |
</script> |
</telerik:RadScriptBlock> |
</form> |
</body> |
I hope this helps.
Sincerely yours,
Georgi Tunev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Thanks for replay, my code is 90% similar to yours, but still displays always 0.
I tried your code on a blank new project and result was the same, it alwayd display 1 (first value from drop down).
If i disable form decorator it works correct.
Print screen while changeinf value 3 to 2: http://cbm.yetiz.pl/telerik/formdecorator_change.jpg
And also screen from FireBug DOM inspector, you can sse that even if 3 is selected the value is still "1": http://cbm.yetiz.pl/telerik/formdecorator_change.jpg
Gr,
Paweł
Are you using Firefox? I am asking you this because the code is working fine with IE, but we noticed that there is a problem with RadFormDecorator's Selects and Firefox. We are currently working on this problem and once we have a solution, I will post it here.
Kind regards,
Georgi Tunev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Hi Paweł,
I believe that the code below will work. It seems that the programatic selection of a dropdown does not behave as expected in FireFox, and we will further investigate the problem.
<script type="text/javascript">
var select = $('#<%= ddlControl.ClientID %>');
var combo = document.getElementById('<%= ddlControl.ClientID %>');
select.change(function()
{
var skinnedcombo = document.getElementById('Skinned<%= ddlControl.ClientID %>');
var skinnedoptions = skinnedcombo.getElementsByTagName('LI');
if(navigator.appName == 'Netscape')
{
for(var i = 0; i < skinnedoptions.length; i ++)
{
combo.options[i].removeAttribute('selected');
if(skinnedoptions[i].className == 'rfdSelect_selected')
{
combo.options.selectedIndex = i;
}
}
}
});
</script>
Kind regards,
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
I am having the same issue on a postback in Firefox. In IE and Safari it works, however when I do a server side postback in Firefox, the first DropDownList item is selected, unless the correct item.
Can anyone assist with this?
Thanks.
The issue you have reported is logged in in our to do list and is pending fixing, however at the time being we cannot provide you with a solution.
Regards,
Martin Ivanov
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
We had a rough day today because of the dropdown.value in javascript does not work in firefox when using the formdecorator.
we finally added the ControlsToSkip="Select" tot he decorator, but i want to know if this matter will be fixed in the comming Q3?
Thanks in advance,
Ilan.
Yes, the fix is ready and will be present in the Q3 release next week.
Regards,
Georgi Tunev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
I just downloaded Q3 and now my DropDownList is no longer styled by RadFormDecorator in IE an FF?
Please advice.
Marc
The decoration of SELECT elements is working fine in our demo, so I assume that the reason for the problem could be in the configuration or the logic that you are using. Please open a support ticket and send us a small sample project so we could investigate.
Best wishes,
Georgi Tunev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
I found that the problem is that I have a CssClass defined on the DropDownList.
In previous versions the select was styled by RadFormDecorator anyway but in Q3 not anymore.
Is this a bug or intended behavior?
BR,
Marc
Yes, by design RadFormDecorator will not decorate controls that have class property - in such case we assume that the developer wants to control the look of the component.
All the best,
Georgi Tunev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.