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

Reset all divs to their default state except for the one that is currently active using jQuery

Here's the plan for my script: Once a user clicks on a "learn more" button, it will reveal the relevant information in the corresponding box. I'm aiming to implement a feature where if you click on another "learn more" button while one box is a ...

I am looking to record my data by utilizing getInitialProps() in next.js

Being a beginner in next.js and react, I am eager to retrieve data from this particular free API link: The component index.js is as follows: import UserList from "./userList"; export default function Home() { return ( <div> &l ...

Alternative function for class helper

Job Details JobID (int, autonumber), Name (varchar), Foreman (int) – Contains EmpID from Employee table … Employee Details EmpID (int, autonumber), FirstName (varchar), LastName (varchar), … Incorporating VB.NET In my Job class, I have included pr ...

Is it possible to dynamically create new input fields by starting their index from the highest number after deletion?

I am working on a feature where users can add new rows with unique IDs and names. Everything works well, but the issue arises when deleting a row other than the last one. Here is an example of my code: $("#add_row").on('click', addRow); funct ...

I need help figuring out how to retrieve the full path of an uploaded file in JavaScript. Currently, it only returns "c:fakepath" but I need

Is there a way to obtain the complete file path of an uploaded file in javascript? Currently, it only shows c:\fakepath. The file path is being directly sent to the controller through jquery, and I need the full path for my servlet. Are there any alte ...

Navigating with React Router using server-side routing in the web browser

I'm currently developing a web application that utilizes react on the client side and express on the server side. For routing the client pages, I've been using react-router (link). Initially, I had success using hashHistory, but now I want to ...

Does JSON.Stringify() change the value of large numbers?

My WCF service operation returns an object with properties of type long and List<string>. When testing the operation in a WCF application, everything functions correctly and the values are accurate. However, when attempting to call the service using ...

What is the process for displaying all "items" from a StreamReader in JObject?

Is there a way to extract the "totalResult" from a StreamReader within a JObject? I am encountering an issue where in the "JO" variable, only 50 values are obtained despite the total indicating 227 values. string link = "https://www.youtube.com/playlist?l ...

Restricting the number of mat-chips in Angular and preventing the input from being disabled

Here is my recreation of a small portion of my project on StackBlitz. I am encountering 4 issues in this snippet: I aim to restrict the user to only one mat-chip. I attempted using [disabled]="selectedOption >=1", but I do not want to disable ...

Seeking assistance in comprehending the method for styling table data using inline CSS in a JavaScript file

I am currently using a JavaScript file that was created for me to update form data based on user selections and display radio buttons along with the corresponding costs. Although the inline CSS in this script works perfectly fine in Chrome and Firefox, it ...

Implement Ajax functionality in C# MVC to dynamically update the values of two dropdown filters

I have created a custom MVC web application that features a table with data that can be filtered using two dropdown menus. One dropdown allows me to select the state value of the data, while the other lets me choose if the data is closed or not (yes/no). W ...

Unusual behavior: Django app not triggering Ajax XHR onload function

I'm currently working on a Django app that features user posts, and I'm in the process of implementing a 'like' / voting system. Initially, I set up this functionality using complete page refreshes combined with a redirect after the vot ...

Retrieve the screen dimensions, including the source code panel and debug panel, utilizing jQuery

$(window).height(); $(window).width(); I am currently utilizing these JavaScript codes to obtain the screen size. However, I have noticed that when the source code panel/debug panel is open, it affects the accuracy of the screen size results. Is there a w ...

Trouble with jQuery event.keyCode in detecting alphanumeric characters

I recently developed a script that is supposed to detect the key the user clicks and perform an action based on whether it is alphanumeric. However, I am encountering an issue as the script does not seem to be working as expected, and I am not receiving an ...

This TypeScript error occurs when trying to assign a value of type 'null' to a parameter that expects a type of 'Error | PromiseLike<Error | undefined> | undefined'

Currently, I am making use of the Mobx Persist Store plugin which allows me to store MobX Store data locally. Although the documentation does not provide a TypeScript version, I made modifications to 2 lines of code (one in the readStore function and anot ...

Transfer the script from package.json to an npm package

In each of our plugins' root directories, there is a file named tools.js. This file contains a build function that assists in creating builds for the plugin. The package.json file references it like this: "scripts": { "build:node&qu ...

Struggling to display the Three.js LightMap?

I'm having trouble getting the lightMap to show on my mesh. Here's the code I'm using: loader.load('model.ctm', function (geometry) { var lm = THREE.ImageUtils.loadTexture('lm.jpg'); var m = THREE.ImageUtils.loadT ...

Ways to assign scores to every response button

Below is an excerpt of code that showcases a list of potential answers for each question in the form of checkbox buttons. The task at hand is to assign marks to each answer button, which can be retrieved from the database. Marks for correct answers are obt ...

Error message: Unable to access .exe file through HTML link

We have a need to include an HTML link on our intranet site that, when clicked, will open an .exe file that is already installed on all user machines. I attempted the following code: <a href = "C:\Program Files\Cisco Systems\VPN&bsol ...

Issue with displaying info window when clicking on marker in react-google-maps

Seeking assistance in opening the info window of specific markers when clicked. All markers and map are displaying correctly, with correct titles appearing on hover. However, clicking a marker does not trigger the info window to show. The console confirms ...