Is bidirectional binding supported by ExtenderControlProperty?

Currently working on an AJAX Extender Control with the goal of sending a value back to the server during post-back.

I'm curious about whether ExtenderControlProperties support two-way communication. If not, is there a workaround to enable this functionality?

Answer №1

It seems that the ExtenderControlProperties do not support two-way binding. I found a workaround by utilizing a hidden field. Here is how I approached it.

I included this code in the extender:

    protected override void OnInit(EventArgs e)
    {
        HiddenFieldId = ClientID + "_HiddenValue";
        Page.ClientScript.RegisterHiddenField(HiddenFieldId, "");
        base.OnInit(e);
    }

    [ExtenderControlProperty]
    [DefaultValue("")]
    public string HiddenFieldId
    {
        get { return GetPropertyValue("HiddenFieldId", ""); }
        set { SetPropertyValue("HiddenFieldId", value); }
    }

    public string HiddenFieldValue
    {
        get { return Page.Request.Form[HiddenFieldId]; }
    }

And I added this section in the behaviour:

//In the prototype
get_HiddenFieldId: function() {
    return this._hiddenFieldId;
},
set_HiddenFieldId: function(value) {
    this._hiddenFieldId = value;
},

//During initialization
this._hiddenFieldId = null;  

//Within my method to set the hidden value.
document.getElementById(this._hiddenFieldId).value = valueToSet;

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

Can the post() method in jQuery be used to invoke a webmethod in asp.net 3.5?

Check out this block of javascript: $.ajax({ type: "POST", url: "default.aspx/GetDate", contentType: "application/json; charset=utf-8", data: {}, dataType: "json", success: function(result) { ale ...

Restrict Fineuploader to uploading only one file at a time

Is there a way to restrict the number of files that can be dropped in the bucket to just one file? I've tried using the validation directive and setting the itemLimit attribute to 1, but it doesn't seem to work as expected. Here's the code s ...

fetch information using ajax and jquery

I'm facing an issue with my ajax request on my website. I'm trying to dynamically fetch pages from a database using jquery and ajax. However, I'm not getting any response, and I'm unsure whether the problem lies in my php code or my j ...

Unlimited scrolling with React and Meteor

Struggling with implementing infinite scrolling in my Meteor and React app. Even after trying multiple npm and Meteor packages, I still can't get it to work. The "createContainer" function subscribes to the entire dataset of "links", but I only want t ...

Accessing an Array from a service method in Angular and passing it to my main component

Within my api-service.ts, I have an array that holds some data. public getData():Observable<any[]> { return Observable.toString[ObsResult]; } Now, in the main component, I am attempting to call the getData() method to render the data in ...

The invalid `autoComplete` prop with a type of `boolean` was passed to `ForwardRef(InputBase)` instead of the expected `string`

Can anyone help me understand why a warning is being thrown when I have an autocomplete feature on this textfield? <TextField type="text" id="standard1" label="Email" ...

Unable to substitute a value using the useState hook in React

Whenever I click a key, I attempt to update the value of a variable but it appears not to be working as intended. ↓ The current implementation is not effective and needs improvement import React, { useState, useEffect } from 'react'; const Li ...

Is it necessary to display a div if the chosen Datatables row contains a span?

Currently, I am dealing with a table that has attachments, but for illustration purposes, I'm using a copyright icon. My challenge lies in displaying or hiding the .newImage block based on whether the row contains a span element (copyright icon) when ...

Change the term to its corresponding translation

I have developed an Ionic Multilingual App that includes a select feature. Within this select, choosing a specific option disables certain page elements. However, I am facing an issue where one of the elements needs to change its text based on the selected ...

Avoiding Dropdown Click Propagation in Bootstrap and AngularJS

When using Bootstrap 3 and AngularJS, I have a list group where each item has a dropdown menu aligned to the right. I want it so that when I click on the dropdown, only the dropdown menu is displayed without triggering the "itemSelected" function for the i ...

Issue with toggleClass being triggered twice while resizing browser window

I am currently in the process of creating a responsive navigation menu. I have completed the initial setup but encountered an issue while resizing the browser window. It appears that the toggleClass function is being triggered multiple times when I resize ...

mobile navigation menu remains open after selecting a link

When the Fixed-to-top navbar is used in mobile view, such as clicking a Navbar icon, it does not collapse afterward while the page is loading. How can I prevent the page from loading in the navbar section? Here is the link to my website: CLICK HERE Addi ...

Is it necessary to specify the server-side script within the "routes" directory?

I'm currently developing a NodeJS Express application and from what I gather, the communication between the server and client is achieved by incorporating an AJAX script in a JavaScript file (on the client-side) and implementing a listener function (f ...

What is preventing me from closing modals when utilizing multiple ones at a time?

I'm currently working on setting up a Bootstrap 4 gallery. I want the images to be clickable and open in a larger version. Everything is working fine, but when I introduce multiple scripts, I can no longer close the modals. Here's the code I hav ...

I am converting a class component to a functional component within a React-Redux-Firebase project

I am currently in the process of rebuilding this component. Check out the updated code here Also, take a look at the project actions script here However, I'm facing an issue with rewriting mapStateToProps and mapDispatchToProps functions. The error ...

Using JavaScript, insert a new date row onto a JSP page

When I click on a hyperlink, I want to add a new row to a jsp page. The functionality is working correctly, but the date function class="dateTxt" is not functioning in the new row. Below are the details of the javascript and jsp function. Javascript: fun ...

Issue with Mjpg paparazzo.js functionality not functioning as expected

I am currently exploring alternative methods to view my security cameras without relying on browser support for mjpg streaming. I have come across Paparazzo.js, which appears to be a promising solution that I want to experiment with: https://github.com/rod ...

Having trouble changing the query string in the URL with Angular 4?

My search form includes various filters such as text inputs, checkboxes, and radio buttons. Whenever the user interacts with these filters, the query string in the URL needs to be updated. Consider the following scenario: http://example.com/search?myFilt ...

Masquerade as a FormsAuthenticated user within an HttpHandler when making a WCF call

When utilizing HttpHandlers to dynamically generate PDF report files, it is essential to maintain the authenticated user context. In order to create the report PDF file, a method on a secure WCF service needs to be invoked with the caller's context (t ...

Managing Input Type Dropdown Selections Using Jquery

I am currently in the process of developing a website. On this website, there is a form that includes 3 dropdown menus as shown below. I would like to implement a feature where selecting the number 5 from the Adults menu will automatically display 5 in the ...