📄 scriptresource(3).axd
字号:
function Sys$WebForms$PageRequestManager$_getScrollPosition() {
var d = document.documentElement;
if (d && (this._validPosition(d.scrollLeft) || this._validPosition(d.scrollTop))) {
return {
x: d.scrollLeft,
y: d.scrollTop
};
}
else {
d = document.body;
if (d && (this._validPosition(d.scrollLeft) || this._validPosition(d.scrollTop))) {
return {
x: d.scrollLeft,
y: d.scrollTop
};
}
else {
if (this._validPosition(window.pageXOffset) || this._validPosition(window.pageYOffset)) {
return {
x: window.pageXOffset,
y: window.pageYOffset
};
}
else {
return {
x: 0,
y: 0
};
}
}
}
}
function Sys$WebForms$PageRequestManager$_initializeInternal(scriptManagerID, formElement) {
if (this._prmInitialized) {
throw Error.invalidOperation(Sys.WebForms.Res.PRM_CannotRegisterTwice);
}
this._prmInitialized = true;
this._scriptManagerID = scriptManagerID;
this._form = formElement;
// TODO: Check that we found the form
this._onsubmit = this._form.onsubmit;
this._form.onsubmit = null;
this._onFormSubmitHandler = Function.createDelegate(this, this._onFormSubmit);
this._onFormElementClickHandler = Function.createDelegate(this, this._onFormElementClick);
this._onWindowUnloadHandler = Function.createDelegate(this, this._onWindowUnload);
Sys.UI.DomEvent.addHandler(this._form, 'submit', this._onFormSubmitHandler);
Sys.UI.DomEvent.addHandler(this._form, 'click', this._onFormElementClickHandler);
Sys.UI.DomEvent.addHandler(window, 'unload', this._onWindowUnloadHandler);
this._originalDoPostBack = window.__doPostBack;
if (this._originalDoPostBack) {
window.__doPostBack = Function.createDelegate(this, this._doPostBack);
}
this._originalDoPostBackWithOptions = window.WebForm_DoPostBackWithOptions;
if (this._originalDoPostBackWithOptions) {
window.WebForm_DoPostBackWithOptions = Function.createDelegate(this, this._doPostBackWithOptions);
}
this._originalFireDefaultButton = window.WebForm_FireDefaultButton;
if (this._originalFireDefaultButton) {
window.WebForm_FireDefaultButton = Function.createDelegate(this, this._fireDefaultButton);
}
this._originalDoCallback = window.WebForm_DoCallback;
if (this._originalDoCallback) {
window.WebForm_DoCallback = Function.createDelegate(this, this._doCallback);
}
this._pageLoadedHandler = Function.createDelegate(this, this._pageLoadedInitialLoad);
Sys.UI.DomEvent.addHandler(window, 'load', this._pageLoadedHandler);
}
function Sys$WebForms$PageRequestManager$_matchesParentIDInList(clientID, parentIDList) {
for (var i = 0; i < parentIDList.length; i++) {
if (clientID.startsWith(parentIDList[i] + "_")) {
return true;
}
}
return false;
}
function Sys$WebForms$PageRequestManager$_onFormElementActive(element, offsetX, offsetY) {
// element: the form element that is active
// offsetX/Y: if the element is an image button, the coordinates of the click
if (element.disabled) {
return;
}
// Check if the element that was clicked on should cause an async postback
this._postBackSettings = this._getPostBackSettings(element, element.name);
if (element.name) {
if (element.tagName === 'INPUT') {
var type = element.type;
if (type === 'submit') {
// DevDiv Bugs 109456: Encode the name as well as the value
this._additionalInput = encodeURIComponent(element.name) + '=' + encodeURIComponent(element.value);
}
else if (type === 'image') {
// DevDiv Bugs 109456: Encode the name as well as the value
this._additionalInput = encodeURIComponent(element.name) + '.x=' + offsetX + '&' + encodeURIComponent(element.name) + '.y=' + offsetY;
}
}
else if ((element.tagName === 'BUTTON') && (element.name.length !== 0) && (element.type === 'submit')) {
// DevDiv Bugs 109456: Encode the name as well as the value
this._additionalInput = encodeURIComponent(element.name) + '=' + encodeURIComponent(element.value);
}
}
}
function Sys$WebForms$PageRequestManager$_onFormElementClick(evt) {
// flag used by fireDefaultButton to know whether calling click() on the default button raised this event.
this._activeDefaultButtonClicked = (evt.target === this._activeDefaultButton);
this._onFormElementActive(evt.target, evt.offsetX, evt.offsetY);
}
function Sys$WebForms$PageRequestManager$_onFormSubmit(evt) {
var continueSubmit = true;
var isCrossPost = this._isCrossPost;
// set to false so subsequent posts that don't go through DPWO aren't considered cross post
this._isCrossPost = false;
// Call the statically declared form onsubmit statement if there was one
if (this._onsubmit) {
continueSubmit = this._onsubmit();
}
// If necessary, call dynamically added form onsubmit statements
if (continueSubmit) {
for (var i = 0; i < this._onSubmitStatements.length; i++) {
if (!this._onSubmitStatements[i]()) {
continueSubmit = false;
break;
}
}
}
if (!continueSubmit) {
if (evt) {
evt.preventDefault();
}
return;
}
var form = this._form;
if (isCrossPost) {
// Allow the default form submit to take place. Since it's a cross-page postback.
return;
}
// DevDiv Bugs 123782
if (this._activeDefaultButton && !this._activeDefaultButtonClicked) {
// we are submitting because a default button's click method was called by _fireDefaultButton
// but calling click() explicitly did not cause a click event or raised it for a different element,
// so we must manually create the correct postback options.
// The button was clicked programmatically, so there are no offsetX or offsetY coordinates.
this._onFormElementActive(this._activeDefaultButton, 0, 0);
}
// If the postback happened from outside an update panel, fall back
// and do a normal postback.
if (!this._postBackSettings.async) {
return;
}
// Construct the form body
var formBody = new Sys.StringBuilder();
// DevDiv Bugs 109456: ScriptManager and UpdatePanel IDs should be encoded as well
formBody.append(encodeURIComponent(this._scriptManagerID) + '=' + encodeURIComponent(this._postBackSettings.panelID) + '&');
var count = form.elements.length;
for (var i = 0; i < count; i++) {
var element = form.elements[i];
var name = element.name;
if (typeof(name) === "undefined" || (name === null) || (name.length === 0)) {
continue;
}
var tagName = element.tagName;
if (tagName === 'INPUT') {
var type = element.type;
if ((type === 'text') ||
(type === 'password') ||
(type === 'hidden') ||
(((type === 'checkbox') || (type === 'radio')) && element.checked)) {
// DevDiv Bugs 109456: Encode the name as well as the value
formBody.append(encodeURIComponent(name));
formBody.append('=');
formBody.append(encodeURIComponent(element.value));
formBody.append('&');
}
}
else if (tagName === 'SELECT') {
var optionCount = element.options.length;
for (var j = 0; j < optionCount; j++) {
var option = element.options[j];
if (option.selected) {
// DevDiv Bugs 109456: Encode the name as well as the value
formBody.append(encodeURIComponent(name));
formBody.append('=');
formBody.append(encodeURIComponent(option.value));
formBody.append('&');
}
}
}
else if (tagName === 'TEXTAREA') {
// DevDiv Bugs 109456: Encode the name as well as the value
formBody.append(encodeURIComponent(name));
formBody.append('=');
formBody.append(encodeURIComponent(element.value));
formBody.append('&');
}
}
if (this._additionalInput) {
formBody.append(this._additionalInput);
this._additionalInput = null;
}
var request = new Sys.Net.WebRequest();
var action = form.action;
if (Sys.Browser.agent === Sys.Browser.InternetExplorer) {
// DevDiv Bugs 85367: In IE we must encode the path portion of the request because XHR doesn't do it for us.
// We only want to encode the path fragment, not the querystring.
var queryIndex = action.indexOf('?');
if (queryIndex !== -1) {
var path = action.substr(0, queryIndex);
if (path.indexOf("%") === -1) {
// only encode if the path portion is not already encoded
// tear off the query, encode, then put the query back
action = encodeURI(path) + action.substr(queryIndex);
}
}
else if (action.indexOf("%") === -1) {
// only encode if the path portion is not already encoded
action = encodeURI(action);
}
}
request.set_url(action);
request.get_headers()['X-MicrosoftAjax'] = 'Delta=true';
request.get_headers()['Cache-Control'] = 'no-cache';
request.set_timeout(this._asyncPostBackTimeout);
request.add_completed(Function.createDelegate(this, this._onFormSubmitCompleted));
request.set_body(formBody.toString());
var handler = this._get_eventHandlerList().getHandler("initializeRequest");
if (handler) {
var eventArgs = new Sys.WebForms.InitializeRequestEventArgs(request, this._postBackSettings.sourceElement);
handler(this, eventArgs);
continueSubmit = !eventArgs.get_cancel();
}
if (!continueSubmit) {
if (evt) {
evt.preventDefault();
}
return;
}
// Save the scroll position
this._scrollPosition = this._getScrollPosition();
// If we're going on to make a new request (i.e. the user didn't cancel), and
// there's still an ongoing request, we have to abort it. If we don't then it
// will exhaust the browser's two connections per server limit very quickly.
this.abortPostBack();
handler = this._get_eventHandlerList().getHandler("beginRequest");
if (handler) {
var eventArgs = new Sys.WebForms.BeginRequestEventArgs(request, this._postBackSettings.sourceElement);
handler(this, eventArgs);
}
// DevDiv Bugs 125825: Cancel any pending callbacks when an async postback begins
if (this._originalDoCallback) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -