{infiniteZest}
// Articles. Tutorials. Utilities.
Home  |   Search  |   Login  
Categories Skip Navigation Links
New / All
AJAX
Apple
ASP.NET
.NET
Git
Google / Android
Python / IronPython
Miscellaneous
SQL Server
AJAX Source Viewer
View the source code of a Method from ASP.NET AJAX Library. Choose a method from the menu items above (Namespaces, Classes, or Methods).
Method '_onFormSubmit(evt)'
Method: _onFormSubmit(evt)
Method Full Name:     Sys$WebForms$PageRequestManager$_onFormSubmit(evt)
Class: PageRequestManager
Namespace: Sys.WebForms
Source File: MicrosoftAjaxWebForms.debug.js
1   function Sys$WebForms$PageRequestManager$_onFormSubmit(evt) {
2     var continueSubmit = true;
3     var isCrossPost = this._isCrossPost;
4     this._isCrossPost = false;
5     if (this._onsubmit) {
6       continueSubmit = this._onsubmit();
7     }
8     if (continueSubmit) {
9       for (var i = 0; i < this._onSubmitStatements.length; i++) {
10        if (!this._onSubmitStatements[i]()) {
11          continueSubmit = false;
12          break;
13        }
14      }
15    }
16    if (!continueSubmit) {
17      if (evt) {
18        evt.preventDefault();
19      }
20      return;
21    }
22    var form = this._form;
23    if (isCrossPost) {
24      return;
25    }
26    if (this._activeDefaultButton && !this._activeDefaultButtonClicked) {
27      this._onFormElementActive(this._activeDefaultButton, 0, 0);
28    }
29    if (!this._postBackSettings.async) {
30      return;
31    }
32    var formBody = new Sys.StringBuilder();
33    formBody.append(encodeURIComponent(this._scriptManagerID) + '=' + encodeURIComponent(this._postBackSettings.panelID) + '&');
34    var count = form.elements.length;
35    for (var i = 0; i < count; i++) {
36      var element = form.elements[i];
37      var name = element.name;
38      if (typeof(name) === "undefined" || (name === null) || (name.length === 0)) {
39        continue;
40      }
41      var tagName = element.tagName;
42      if (tagName === 'INPUT') {
43        var type = element.type;
44        if ((type === 'text') ||
45        (type === 'password') ||
46        (type === 'hidden') ||
47        (((type === 'checkbox') || (type === 'radio')) && element.checked)) {
48          formBody.append(encodeURIComponent(name));
49          formBody.append('=');
50          formBody.append(encodeURIComponent(element.value));
51          formBody.append('&');
52        }
53      }
54      else if (tagName === 'SELECT') {
55        var optionCount = element.options.length;
56        for (var j = 0; j < optionCount; j++) {
57          var option = element.options[j];
58          if (option.selected) {
59            formBody.append(encodeURIComponent(name));
60            formBody.append('=');
61            formBody.append(encodeURIComponent(option.value));
62            formBody.append('&');
63          }
64        }
65      }
66      else if (tagName === 'TEXTAREA') {
67        formBody.append(encodeURIComponent(name));
68        formBody.append('=');
69        formBody.append(encodeURIComponent(element.value));
70        formBody.append('&');
71      }
72    }
73    if (this._additionalInput) {
74      formBody.append(this._additionalInput);
75      this._additionalInput = null;
76    }
77    
78    var request = new Sys.Net.WebRequest();
79    var action = form.action;
80    if (Sys.Browser.agent === Sys.Browser.InternetExplorer) {
81      var queryIndex = action.indexOf('?');
82      if (queryIndex !== -1) {
83        var path = action.substr(0, queryIndex);
84        if (path.indexOf("%") === -1) {
85          action = encodeURI(path) + action.substr(queryIndex);
86        }
87      }
88      else if (action.indexOf("%") === -1) {
89        action = encodeURI(action);
90      }
91    }
92    request.set_url(action);
93    request.get_headers()['X-MicrosoftAjax'] = 'Delta=true';
94    request.get_headers()['Cache-Control'] = 'no-cache';
95    request.set_timeout(this._asyncPostBackTimeout);
96    request.add_completed(Function.createDelegate(this, this._onFormSubmitCompleted));
97    request.set_body(formBody.toString());
98    var handler = this._get_eventHandlerList().getHandler("initializeRequest");
99    if (handler) {
100     var eventArgs = new Sys.WebForms.InitializeRequestEventArgs(request, this._postBackSettings.sourceElement);
101     handler(this, eventArgs);
102     continueSubmit = !eventArgs.get_cancel();
103   }
104   if (!continueSubmit) {
105     if (evt) {
106       evt.preventDefault();
107     }
108     return;
109   }
110   this._scrollPosition = this._getScrollPosition();
111   this.abortPostBack();
112   handler = this._get_eventHandlerList().getHandler("beginRequest");
113   if (handler) {
114     var eventArgs = new Sys.WebForms.BeginRequestEventArgs(request, this._postBackSettings.sourceElement);
115     handler(this, eventArgs);
116   }
117   
118   if (this._originalDoCallback) {
119     this._cancelPendingCallbacks();
120   }
121   this._request = request;
122   request.invoke();
123   if (evt) {
124     evt.preventDefault();
125   }
126 }
This is the JavaScript source for method _onFormSubmit(evt) from ASP.NET AJAX Library. Full name for this method is Sys$WebForms$PageRequestManager$_onFormSubmit(evt). It belongs to the class PageRequestManager, which is in Sys.WebForms namespace. This source is in MicrosoftAjaxWebForms.debug.js file.
Bookmark and Share This
About  Contact  Privacy Policy  Site Map