Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
Display Error Messages returned from server
08/10/2009
00:34
Avatar
chedebalakrishna
Member
Members
Forum Posts: 4
Member Since:
08/10/2009
sp_UserOfflineSmall Offline

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.

08/10/2009
01:43
Avatar
Rumen[Trirand]
Moderator
Members

Moderators
Forum Posts: 81
Member Since:
08/10/2009
sp_UserOfflineSmall Offline

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

http://www.trirand.net

08/10/2009
11:25
Avatar
chedebalakrishna
Member
Members
Forum Posts: 4
Member Since:
08/10/2009
sp_UserOfflineSmall Offline

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.

08/10/2009
12:10
Avatar
Rumen[Trirand]
Moderator
Members

Moderators
Forum Posts: 81
Member Since:
08/10/2009
sp_UserOfflineSmall Offline

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

http://www.trirand.net

08/10/2009
12:12
Avatar
Rumen[Trirand]
Moderator
Members

Moderators
Forum Posts: 81
Member Since:
08/10/2009
sp_UserOfflineSmall Offline

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

http://www.trirand.net

08/10/2009
18:19
Avatar
chedebalakrishna
Member
Members
Forum Posts: 4
Member Since:
08/10/2009
sp_UserOfflineSmall Offline

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.

09/10/2009
04:27
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

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.

09/10/2009
12:08
Avatar
chedebalakrishna
Member
Members
Forum Posts: 4
Member Since:
08/10/2009
sp_UserOfflineSmall Offline

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/10/2009
12:11
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

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.

Forum Timezone: Europe/Sofia

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.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information