What effect does setting AutoPostBack to "true" in an ASP dropdownlist have on the fireEvent() function?

I am currently working on an aspx page. This page includes three dropdown lists and a button, all of which are populated dynamically based on the code written in the code-behind file (.cs file). To achieve this, I need to utilize two event handler methods for the first two dropdown lists with AutoPostBack="true". After clicking the button, the Javascript file should trigger fireEvent(), passing an object that contains the selected value. However, I am encountering an issue where the page is not firing the event. I would appreciate any help in resolving this problem. Below is the code for my aspx page:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PopupReference.aspx.cs"
Inherits="ButtonReference.Popups.PopupReference" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Reference Button Popup</title>  
</head>
<body>
    <form id="form1" runat="server">

    <div>
        <h1>
            Reference Button Popup</h1>
        <p>
            <asp:DropDownList ID="lookupcompDropdown" runat="server" AutoPostBack="true" onselectedindexchanged="lookupcomp_SelectedIndexChanged" >
            </asp:DropDownList>
            <asp:DropDownList ID="embeddedschemaDropdown" runat="server" AutoPostBack="true" onselectedindexchanged="embeddedschema_SelectedIndexChanged">
            </asp:DropDownList>
            <asp:DropDownList ID="lookupvaluesDropdown" runat="server" AutoPostBack="false">
            </asp:DropDownList>
            <asp:Button ID="Submit" runat="server" Text="Submit" />

        </p>
    </div>
    </form>
</body>
</html>

Javascript file:

Type.registerNamespace("RTFExtensions.Popups");

RTFExtensions.Popups.PopupReference = function (element) {
    Type.enableInterface(this, "RTFExtensions.Popups.PopupReference");
    this.addInterface("Tridion.Cme.View");
};

    RTFExtensions.Popups.PopupReference.prototype.initialize = function () {
        alert("initialized");    
        $log.message("Initializing Button Reference popup...");
        this.callBase("Tridion.Cme.View", "initialize");

        var p = this.properties;
        var c = p.controls;

        p.HtmlValue = { value: null };
        ($("#DropDownList1"), "System.Web.UI.WebControls.DropDownList");
            c.SubmitButon = $("#Submit");

    //asp dropdown
        c.DropDown = $("#lookupvaluesDropdown");
        $evt.addEventHandler(c.SubmitButon, "click", this.getDelegate(this._execute));
        $evt.addEventHandler(c.InsertButton, "click", this.getDelegate(this._execute));

    };

    RTFExtensions.Popups.PopupReference.prototype._execute = function () {
        alert("executing");
        //alert($("#lookupvaluesDropdown").value);
        this.properties.HtmlValue.value = $("#lookupvaluesDropdown").value;
        alert(this.properties.HtmlValue.value+"in execute");
        alert(this.fireEvent("submit1", this.properties.HtmlValue));
        //$("#Submit").fireEvent("submit1", this.properties.HtmlValue);
        window.close();
    };

    $display.registerView(RTFExtensions.Popups.PopupReference); 

Answer №1

Could you please provide more details about your question? From what I gather

Are you using an asp button? If so, consider utilizing the OnClientClick event to invoke the javascript function. You can access the dropdownlist elements within your javascript function for manipulation.

It seems like your event is triggering (consider debugging your javascript), but a new page is being rendered upon postback. Try using a regular HTML button instead of an ASP button.

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

The Angular route functions flawlessly in the development environment, but encounters issues when deployed to

I have a project built with Angular 2, During development on localhost, everything runs smoothly. However, once I build a production version using (npm run build: prod) and navigate to the route on the server, I encounter a 404 error indicating that the r ...

What methods can be used to accomplish this effect using CSS and/or Javascript?

Is there a way to achieve the desired effect using just a single line of text and CSS, instead of multiple heading tags and a CSS class like shown in the image below? Current Code : <h2 class="heading">Hi guys, How can i achieve this effect using j ...

Issue with vertical alignment of text inside select dropdown in Material UI Core

Take a look at the image. The text isn't centered in the text box like the other fields on the form. Dropdown Alignment Issue Below is my code snippet: <FormControl style={{ width: "80%" }} size="small"> <InputLabel htmlFor="Implement ...

Send information using jQuery AJAX

Currently, I am attempting to use AJAX to submit data to my table. Below is the form I have created for this purpose: <form> Total <input type="text" id="total" name="total" /><br /> Bill name<input type="text" id="bill-name" ...

Steps to obtain an Element binding from a Svelte component

Is it possible to retrieve the bounding client rect of an anchor element? I typically mark this using the syntax bind:this={someVariable}. However, when I add this code to a Svelte component, I receive a different object that Svelte uses to represent a c ...

Retrieve an Excel file through a web API with the help of AngularJS

Client-side Code var url = baseUrl+ "/api/Home/DownloadReport"; window.open(url); Server-side Code [HttpGet] public HttpResponseMessage DownloadReport() { var stream = new System.IO.MemoryStream(File.ReadAllBytes(@"C:\Users\my ...

Passing data as a parameter from the view to the controller using AngularJS

I am attempting to retrieve data from a view, which must be passed as a parameter in a function in order to populate an array in the controller. However, I am not receiving any objects in return. Here is what I have tried: VIEW <div ng-repeat="cssfram ...

When working with AngularJS, you can enhance your application by implementing a global AJAX error handler if one has

Is there a way to set a global AJAX handler that will only be called if an error handler is not already defined for a specific AJAX call? Some of my AJAX calls need to execute certain logic if an error occurs (such as re-enabling a button), while others s ...

Dealing with error management in Transfer-Encoding chunked HTTP requests using express and axios

My current challenge involves fetching a large amount of data from a database in JavaScript using streaming to avoid loading all the data into memory at once. I am utilizing express as my server and a nodeJS client that retrieves the data using Axios. Whil ...

Do developers only need type definitions for npm packages on their local machines?

It is my understanding that type definition modules for npm packages offer developers intellisense, eliminating the need to guess parameter types when using library methods. These modules have proven to be extremely valuable in my typescript project, esp ...

Retrieving information from various datasets through inquiry

First Model const mongoose = require("mongoose"); const finalApprovalSchema = mongoose.Schema({ formId: String, designApproval: String, rejectionReason: String, date: { type: Date, default: Date.now, }, }); const FinalApproval ...

Bring the element to the top of the page by clicking on the anchor within the element or anywhere within the specified div ID

I am looking to implement a functionality where the page scrolls to the top of the navigation div ID when a link inside the navigation div is clicked, or ideally even when clicking anywhere within the div itself that contains the navigation links. After r ...

Is there a way to change a string that says "False" into a Boolean value representing false?

When retrieving values from the backend, I am receiving them as strings 'True' and 'False'. I have been attempting to convert these values into actual Boolean values, however, my current method always returns true. What is the correct a ...

Transform a flat 2D shape into a dynamic 3D projection using d3.js, then customize the height based on the specific value from ANG

Currently, I am utilizing d3.js version 6 to generate a 3D representation of the 2D chart shown below. Within this circle are numerous squares, each colored based on its assigned value. The intensity of the color increases with higher values. My goal is t ...

Access the most recent state value with React's Context API

Trying out the React context API, Take a look at the someComponent function where I pass the click event (updateName function) to update the value of state.name from the GlobalProvider function. After updating state.name, it reflects in the browser but t ...

Is it possible to activate the jQuery .click() function for a button with specific text?

Here's a dilemma I'm facing: $('.add_to_cart span:contains("Choose a Size")').click(function() { console.log("it has been clicked") }); <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></s ...

Encountering an issue while updating information following the migration to vue-chartjs 4

I recently upgraded from vue-chartjs version 3 to version 4. I successfully migrated my LineChart component by updating the template section and removing the draw method calls. This component is utilized for two separate charts. However, when I close the ...

Error Encountered - Configuring Node.js Deployment on the Heroku Platform

"APPLICATION ERROR - Oops! Looks like something went wrong with the application and we couldn't load your page. Please give it another shot in a little while. If you are the app owner, make sure to review your logs for more information." Hey there - ...

I am looking to showcase a series of icons linked together by connecting lines

I have successfully designed the layout and added icons, but I am facing difficulty in creating connecting lines between them. I attempted to utilize CSS borders and pseudo-elements, yet I cannot achieve the desired outcome. If anyone could offer a CSS-ba ...

Displaying a message when there are no results in Vue.js using transition-group and encountering the error message "children must be keyed

Utilizing vue.js, I crafted a small data filter tool that boasts sleek transitions for added flair. However, I encountered an issue with displaying a message when there are no results matching the current filters. Here's what I attempted: <transit ...