简体   繁体   中英

Is there any impact on fireEvent(), if I use AutoPostBack=“true” in asp dropdownlist?

I am developing a aspx page. In the page I have three dropdownlists and a button. All these dropdownlists will be dynamically populated based on the code written code behind file (.cs file). For that purpose I need to use two event handler methods for first two dropdownlists with AutoPostBack="true" . Then after clicking the button in the Javascript file it should fireEvent() having a object which consists the selected value. But the page is not firing the event. Please help me in solving this issue. PFB my code for 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); 

Please clarify your question. As far my understanding

Is your Button an asp button, if so, try using OnClientClick event to call the javascript function. Access those dropdownlist within your javascript function to manipulate them.

Your event is firing (try debugging your javascript) but on postback a brand new page is rendered. Try using a normal HTML button instead of an ASP button.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM