Forum


00:34

08/10/2009

Hi,
I am using the JQuery Grid in ASP.NET MVC. How to display the Error Messages, for the Exceptions occured on the server side.
For any Exception occured on the server I need to display a message "Error while processing..please contact Administrator". This message is to be shown on top of the Grid.
In the demos i see the following code :
loadError : function(xhr,st,err) {
jQuery("#rsperror").html("Type: "+st+"; Response: "+ xhr.status + " "+xhr.statusText);
How we need to frame the JSON string when some error occurs on the server side, so that the function pointed by "loadError" gets called.
Appreciate, if you can share some sample code
Thanks,
Balakrishna.
01:43

Moderators
08/10/2009

There is an example demonstrating how you can control that
Visit our demos:
http://trirand.com/jqgrid/jqgrid.html
Then click "New in Version 3.2", and then "Cotrolling Server Errors" to see an example how you can show custom error in the grid upon server error.
Trirand ASP.NET WebForms & MVC components based on jQuery & ThemeRoller
11:25

08/10/2009

Hi Rumen,
Thanks for the reply.
I looked at it and I did not understood. The code that I have posted above, is taken from the same example that you have refered.
I am using JSON string to populate the JQuery Grid. What I need is, in case some error occurs on server side, how can i send back that error in the JSON string so that the function pointed by “loadError” (in javascript) gets called.
Sorry..if i am not clear in explaining.
Thanks,
Balakrishna.
12:10

Moderators
08/10/2009

In ASP.NET, you would just write directly to Response, then in case of error just End() the Response stream. Then, what is sent to client will be displayed by the grid, e.g.
try
{
// something
}
catch (e)
{
Response.Write(responseText);
Response.Flush();
Response.End();
}
Trirand ASP.NET WebForms & MVC components based on jQuery & ThemeRoller
12:12

Moderators
08/10/2009

In ASP.NET, you would just write directly to Response, then in case of error just End() the Response stream. Then, what is sent to client will be displayed by the grid, e.g.
try
{
// something
}
catch (e)
{
Response.Write(responseText);
Response.Flush();
Response.End();
}
Trirand ASP.NET WebForms & MVC components based on jQuery & ThemeRoller
18:19

08/10/2009

Hi,
I tried the way you demonstrated. But its now working. I end up seeing a javascript error stating "Expected ) ".
I tried in a different way..
try
{
// something
}
catch (e)
{
throw new Excetion ("Error Message");
}
And in the JQuery query Grid , I used the below code. But I could not get the error Message returned from the server. Are there any properties with the "err" object, that can give the message sent from the server..? For time being I am hard coding the message in the Jquery grid.
loadError : function(xhr,st,err) {
jQuery(”#rsperror”).html("Meeage Hardcode here...But Message from server need to be dsiplayed");
Thanks
Balakrishna.
04:27

Moderators
30/10/2007

Hello,
I sugest you to use FireFox and do
loadError : function(xhr,st,err) {
console.log(xhr);
console.log(st);
console.log(err);
}
In order to see what you have from server
Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
12:08

08/10/2009

Hi Tony,
I have written the below code in my javascirpt file
Server Code :
-----------------
try
{
if (!String.IsNullOrEmpty(delIDs))
{
_rolesRepository.DeleteFunctionalAreaAdministrators(delIDs);
}
}
catch (RulesException ex)
{
throw new Exception("User Attempted to delete the last functional area administrator"
);
Client Side JavaScript :
-----------------------------
loadError:
function(xhr, st, err) {
jQuery("#rsperror").html(xhr.status + xhr.statusText + st+ err);
)
I see the below error on IE, Mozilla FireFox and Chrome
500Internal Server ErrorNaNundefined
The actual error Message returned from server in the exception "Attempt to delete last administrator is failed". I should able to get this message from either of xhr, st or err objects.
Thanks,
Balakrishna.
12:11

Moderators
30/10/2007

Hello,
Could you please try to accept your message with a simple ajax calls - not using jqGrid?
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
Most Users Ever Online: 715
Currently Online:
73 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66