Quantcast
Channel: AjaxControlToolkit Work Item Rss Feed
Viewing all articles
Browse latest Browse all 4356

Closed Issue: Wrong eventArgs for PageRequestManager.add_beginRequest if using LinkButtons [27272]

$
0
0
I encountered a bug within the PageRequestManager when using LinkButtons for async/ajax Updates.

If you add a listener to the Sys.WebForms.PageRequestManager.add_beginRequest event and raise an async postback using a LinkButton, the eventArgs will be empty (no postBackElement or panelsToUpdate will be set).

An example can be found in this Forum Post: http://forums.asp.net/t/1841094.aspx/1

The bug is in the _doPostBack Method of the PageRequestManager.

Checkout the _doPostBack method in http://ajaxcontroltoolkit.codeplex.com/SourceControl/changeset/view/1014bf767f65#Client%2fMicrosoftAjax%2fExtensions%2fSys%2fWebForms%2fPageRequestManager.js

There is this code piece:

var mpUniqueID = this._masterPageUniqueID;
// If it's not a cross-page post, see if we can find the DOM element that caused the postback
var clientID = this._uniqueIDToClientID(eventTarget);
var postBackElement = document.getElementById(clientID);
if (!postBackElement && mpUniqueID) {
if (clientID.indexOf(mpUniqueID + "$") === 0) {
// With ClientIDMode=Predictable, the MasterPageID is missing from the beginning
// of the client ID.
postBackElement = document.getElementById(clientID.substr(mpUniqueID.length + 1));
}
}

But the check in the inner if-condition is wrong! The clientID will never contain the masterPageUniqueID since it is a clientID (seperated with underscores) converted from a uniqueID (seperated with dollars). The check need to be done on the uniqueID which is stored in the eventTarget.

var mpUniqueID = this._masterPageUniqueID;
// If it's not a cross-page post, see if we can find the DOM element that caused the postback
var clientID = this._uniqueIDToClientID(eventTarget);
var postBackElement = document.getElementById(clientID);
if (!postBackElement && mpUniqueID) {
if (eventTarget.indexOf(mpUniqueID + "$") === 0) {
// With ClientIDMode=Predictable, the MasterPageID is missing from the beginning
// of the client ID.
clientID = eventTarget.substr(mpUniqueID.length + 1)
postBackElement = document.getElementById(clientID);
}
}

After this fix the postBackElement can be found and the eventArgs contain the valid data.

Viewing all articles
Browse latest Browse all 4356

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>