PDA

View Full Version : Need URGENT help with a .ashx handler, please!!



KingKahn
22 Apr 2009, 7:03 PM
I have a aspx page with a single div tag called main. The js source is in another file called Main.js. I am testing this code with hard code values just to iron out communication issues between the client and the server. On my page I have 4 accordions. One of the accordions contains three text fields and a button. I have declared an anonymous handler for the button click. When the user clicks the button I want the code to call my async handler defined in a seperate.ashx file - but this never happens. The code always falls into the fail handler of the call back. What am I doing wrong over here? Thanks in advance for your time and consideration.



Ext.onReady(function() {
var tabs = new Ext.TabPanel({
renderTo: 'main',
width: 1130,
height: 800,
activeTab: 0,
frame: true,
xtype: 'tabpanel',
defaults: {
autoHeight: true
},
items: [{
title: 'Registration',
// First tab panel - Registration
layout: 'accordion',
// Accordion object literal properties
layoutConfig: {
titleCollapse: true,
animate: true,
activeOnTop: true
},
defaults: {
bodyStyle: 'padding:15px',
collapsed: false
},
items: [{ // Search accordion defs
title: 'LOOK UP - Search Customers',
layout: 'form',
id: 'searchForm',
labelWidth: 105,
height: 300,
frame: true,
bodyStyle: 'padding:5px',
autoWidth: true,
items: [{
xtype: 'fieldset',
title: 'Search',
autoHeight: true,
collapsible: true,
items: [{
layout: 'form',
defaultType: "textfield",
defaults: {
allowBlank: true
},
items: [{
fieldLabel: 'E-Ticket Number',
id: 'txtETicketNumber',
width: 700
},
{
xtype: 'button',
text: 'Go',
id: 'bntGo',
handler: function() {
mask = new Ext.LoadMask(Ext.getBody(), {
msg: "Performing Search..."
});
mask.show();
//Ext.lib.Ajax.defaultPostHeader = 'application/json';
Ext.Ajax.request({
url: 'previewAttendanceInfo.ashx',
method: 'GET',
params: {
"eventSessionId": 'M8DIL6NVROUR'
},
success: function(response, options) {
mask.hide();
Ext.MessageBox.alert(response.responseText);
},
failure: function(response, options) {
mask.hide();
Ext.MessageBox.alert('Failed', response);
}
});
}
},
{
fieldLabel: 'Last Name',
id: 'txtLastName',
width: 200
},
{
fieldLabel: 'Zip Code:',
id: 'txtZipCode',
width: 200
}]
}] // Field Defs
}]
},
{
title: 'Pre-Registered',
frame: true,
bodyStyle: 'padding:5px',
height: 300,
autoWidth: true
},
{
title: 'Attendance',
frame: true,
bodyStyle: 'padding:5px',
autoWidth: true,
height: 300
},
{
title: 'Purchase',
frame: true,
bodyStyle: 'padding:5px',
autoWidth: true,
height: 300
}] // accordion items
},
{
title: 'Report & Finalize'
},
// Second tab panel - Report & Finalize
{
title: 'Session Info'
} // Third tab panel - Session Info
] // Main tabs end
}).show(); // Tabs
});
function getETicketNumber() {
alert('in function');
mask.show();
Ext.lib.Ajax.defaultPostHeader = 'application/json';
Ext.Ajax.request({
url: '/previewAttendanceInfo.ashx',
method: 'POST',
params: Ext.encode(params),
success: function(response, options) {
mask.hide();
Ext.get('txtResult').dom.value = response.responseText;
Ext.get('additionResponse').dom.innerHTML = response.responseText;
},
failure: function(response, options) {
mask.hide();
Ext.MessageBox.alert('Failed', 'Unable to add values');
}
});
}

KingKahn
22 Apr 2009, 7:08 PM
Well the code may help someone at least. After I am done with this I am going to post a working example of how to call a .ashx handler from js so it may save someone else a lot of grief!

jay@moduscreate.com
23 Apr 2009, 2:50 AM
Please do not place the term 'urgent' in your thread titles.

wayne_o
23 Apr 2009, 2:52 AM
If you're using VS08 you can put breakpoints in the JS code - no need of those nasty



alert('in function');


dotted all over the place :)

w://

kora.kanchan
23 Apr 2009, 4:11 AM
i think that your handler path is not correct..
what is the file structure of ashx,aspx and js?
is js file called the handler?

put the breakpoint in handler.