If you want to make your own module in AspxCommerce this technique will be helpful to you.
1. add control to your module2. add Test.js in your module
3. in Test.js copy and paste the code as under.
4. Do all operations here as a code behind in your Asp.Net page.
var TestPage = '';
$(function () {
var ModuleServicePath = modulePath + "Services/WebService.asmx/";
var aspxCommonObj = {
StoreID: 1,
PortalID: 1,
UserName: "username",
CultureName: "en_US",
CustomerID: 25
};
TestPage = {
config: {
isPostBack: false,
async: false,
cache: false,
type: 'POST',
contentType: "application/json; charset=utf-8",
data: '{}',
dataType: 'json',
baseURL: AspxCommerce.utils.GetAspxServicePath(),
method: "",
url: "",
ajaxCallMode: "",
error: "",
sessionValue: ""
},
ajaxCall: function (config) {
$.ajax({
type: TestPage.config.type,
contentType: TestPage.config.contentType,
cache: TestPage.config.cache,
async: TestPage.config.async,
url: TestPage.config.url,
data: TestPage.config.data,
dataType: TestPage.config.dataType,
success: TestPage.config.ajaxCallMode,
error: TestPage.config.error
});
},
Init: function () {
$("#btnSaveTest").click(function () {
if (frm.form()) {
TestPage.SaveUpdate();
}
});
},
SaveUpdate: function () {
this.config.method = "SaveUpdate";
this.config.url = ModuleServicePath + this.config.method;
this.config.data = JSON2.stringify({ aspxCommonObj: aspxCommonObj });
this.config.ajaxCallMode = TestPage.SaveUpdateSuccess;
this.config.error = TestPage.SaveUpdateError;
this.ajaxCall(this.config);
},
SaveUpdateSuccess: function (msg) {
csscody.info("<h2>Successful Message</h2><p>Saved successfully!</p>");
},
SaveUpdateError: function () {
csscody.error("<h2>Error Message</h2><p>Failed to save!</p>");
}
};
TestPage.Init();
});
No comments:
Post a Comment