The OnClientSelectedIndexChanged event is not triggering when the dropdown selection is changed

I'm experiencing an issue with my OnClientSelectedIndexChanged javascript function not firing when the dropdown selected value is changed. Despite placing a breakpoint on the first line of the javascript function, it never gets reached.

<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">       
        <script type="text/javascript" >
            function ddl_AutoSchedule_SelectedIndexChanged(sender, eventargs) {
                var date_DueDate = $find("#date_DueDate");
                var date_PlannedStart = $find("#date_PlannedStart");
                var date_PlannedFinish = $find("#date_PlannedFinish");
                date_DueDate.value = Now.AddDays(sender.value);
                date_PlannedStart.value = Now.AddDays(0);
                date_PlannedFinish.value = Now.AddDays(sender.value);
            }
        </script>
    </telerik:RadCodeBlock>

Here is my dropdown:

<telerik:RadDropDownList ID="ddl_AutoSchedule" runat="server" Enabled="false" AutoPostBack="True" OnClientSelectedIndexChanged="ddl_AutoSchedule_SelectedIndexChanged">
        <Items>
           <telerik:DropDownListItem Value="0" Text="Select a Schedule" />
           <telerik:DropDownListItem Value="30" Text="30 Days" />
           <telerik:DropDownListItem Value="45" Text="45 Days" />
           <telerik:DropDownListItem Value="60" Text="60 Days" />
           <telerik:DropDownListItem Value="90" Text="90 Days" />
           <telerik:DropDownListItem Value="120" Text="120 Days" />
           <telerik:DropDownListItem Value="180" Text="180 Days (6 Months)" />
           <telerik:DropDownListItem Value="270" Text="270 Days (9 Months)" />
           <telerik:DropDownListItem Value="365" Text="365 Days (1 Year)" />
        </Items>
    </telerik:RadDropDownList>

Answer №1

After reviewing the examples provided in the documentation, it appears that there is no necessity to enclose your JS function within a RadCodeBlock control.

You can simply add the <script> block directly to the page and it should execute correctly.

<script type="text/javascript">
    function ddl_AutoSchedule_SelectedIndexChanged(sender, eventargs) 
    {
        var date_DueDate = $find("#date_DueDate");
        var date_PlannedStart = $find("#date_PlannedStart");
        var date_PlannedFinish = $find("#date_PlannedFinish");
        date_DueDate.value = Now.AddDays(sender.value);
        date_PlannedStart.value = Now.AddDays(0);
        date_PlannedFinish.value = Now.AddDays(sender.value);
    }
</script>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

refresh information using ckeditor

I've been facing an issue with updating the content in my CKEditor <textarea id="monday" class="ckeditor" name="monday" >1</textarea> <script type="text/javascript" > setTimeout(function(){ $('#monday').val(&ap ...

Activate Meteor's spinner when invoking a method

I am currently working on implementing a functionality where I have a button that triggers a method. The requirement is for the button to change and display a spinner inside it when the method is called. So far, I have structured the button itself along w ...

The tabbed menu should remain selected until the user switches to another menu option

Each time a user clicks on a tabbed menu, the selected menu should be highlighted in the background color until another tab is clicked. Each tab corresponds to a different page of content. In order to achieve this, the selected tab needs to have the attri ...

How to update a nested object within an array in mongoose by referencing its specific id

Here is a glimpse of my database where I am looking to update an object within the perDayDetails array using its unique identifier in Mongoose. "_id":{"$oid":"612f45863106a21bc0506a36"}, "fullname":"abc xyz" ...

Achieving a draggable object to land on a designated target

Before you jump to conclusions based on the title, let me clarify that I am not referring to jQuery UI draggable. Instead, I am discussing a plugin that I am currently developing for the community. The goal of my plugin is to create a designated target fea ...

Is it possible to apply v-model to a function that toggles a particular accordion panel?

I am curious about a possibility in my specific situation. I have two Vue/Element UI accordions on a page and I've created an "open all, close all" button for them. How can I assign a unique ID to each accordion and then pass that ID to the function t ...

Choose Select2 to remove all selected options

I'm looking for a way to remove all selected values in one click without having to specify each individual 'id' separately. I've tried experimenting with different approaches, but so far, I've only been able to deselect the first ...

How to Generate an Array of JSON Objects in JavaScript on a Razor Page using a Custom ViewModel in MVC?

Attempting to populate the array within my script for future charting with D3.JS, I came across some issues. Following advice from this post, I used a specific syntax that unfortunately resulted in an error stating "Uncaught ReferenceError: WebSite is not ...

The alert feature does not seem to be functioning properly when displaying error messages

// Issue: Alert is not working on error message. I intend to only display up to four issues, after that it should not work. success: function(msg, String, jqXHR) { window.location = 'home.html'; $("#result").html(msg, String, jqX ...

Trouble linking storage to database on Firebase with Vue.js

I'm currently diving into my Vue project integrating firebase to create locations with specialized images and data. I've been following a tutorial but it seems a bit outdated, especially when trying to connect Firebase storage with the database. ...

Observable in RxJS with a dynamic interval

Trying to figure out how to dynamically change the interval of an observable that is supposed to perform an action every X seconds has been quite challenging. It seems that Observables cannot be redefined once they are set, so simply trying to redefine the ...

An ASP.NET MVC project deployed on Azure integrating with clearDB mySQL through SSL authentication

I am utilizing a complimentary subscription on Azure that includes a web application and a small mySQL database from cleardb.com (Dreamspark). ClearDB offers certificate downloads for SSL authentication to the database, and I have successfully connected to ...

Tips for receiving notifications when the Collapsible collapses

I'm having trouble figuring out how to receive notifications when the Collapsible is expanded and collapsed. Currently, I am not receiving any type of notification. Any suggestions on how to make this work? Below is my code: --Imported jQuery < ...

Transform JSON String into Object using jQuery

Recently, I came across a JSON String in this format. {"label":"label","label1":"67041","label2":"745","label3":"45191","label4":"11‌​464"} I needed to convert it into an object structure like this [{"label":"label","label1":"67041","label2":"745"," ...

Looping through jQuery, I am adding divs, but frustratingly I can only insert text into the initial div created. Why

var numPills = 3 for(var i=0; i< numPills; i++){ //var currentPill = JUser.pill1.; $(".col-r-in").append( $('<div/>') .attr("id", "medsProgress") .addClass("roundedBar") ); $('#medsProgress').append( $('<div/>&apo ...

Issue: When calling setState(...), you must provide either an object containing the state variables to update or a function that will return an object with the updated

Encountering an error in the else section with this.state.incorrect + 1 and this.state.correct + 1 I've come across a similar issue that wasn't resolved by visiting this link: React Native: setState(...): takes an object of state variables to up ...

The Randomizer consistently yields the initial value each time

My mom works as a teacher, and I planned to surprise her with a random student picker for her 2nd-grade class. However, there seems to be an issue as it always selects the same student - Daniel. Despite setting up logging for the random numbers generated, ...

Is there a way to determine the number of clicks on something?

I'm attempting to track the number of times a click event occurs. What is the best method to achieve this? There are two elements present on the page and I need to monitor clicks on both of them. The pseudo-code I have in mind looks something like ...

NextJS does not automatically define environment variables

My current challenge involves working with the next-auth library, which relies on using environment variables in a specific way: Providers.GitHub({ clientId: process.env.GITHUB_ID, clientSecret: process.env.GITHUB_SECRET, }), Despite following ...

Picture that perfectly matches the height of the window

I am looking to create a website design similar to this where an image fills the window until you scroll down. I am not sure how to accomplish this. Would using jQuery be the best option? I haven't been able to find much information on this. While my ...