Showing posts with label catch. Show all posts
Showing posts with label catch. Show all posts

Monday, March 26, 2012

Catch the active tab changed event in javascript

Hi,

I have been using the ajax tab control.

I need to catch the activetab changed event of javascript.

I want to do some processing when the users goes to a specific tab.

It would be very helpful if someone can tell me how i can do it.

Cheers

Sohail

Hi,

Well looks like i got how to catch the activetab changed event

the tab container has OnClientActiveTabChanged event.

However i still need to get some way to acces the active index in the javascript so based on it i can do some processing.

Please let me know the soltn

Cheers

Sohail Sayed


Hi Sohail,

You can use the following script to get the index of active tab:


var tc = $find("TabContainer1"); // "TabContainer1" is the client id of the TabContainer control.

var index = tc.get_activeTabIndex();

Hope this helps.


Hi,

Thx i am now able to get the active index

Catch async trigger in page_load

Hi guys,

I've recently started experiencing with the ASP.NET AJAX toolkit and I'm wondering if it's possible to catch the async trigger in the page_load and what object caused it?

This is in the situation that I have a lot of database accesses in the app. I want to be able to trigger really specific calls to the DB depending on if it's a postback, async call, etc. Not just a generic thing that's executed in the !isPostback section, causing the application to fetch a lot of data for a small AJAX call.

Thanks,

Ben.

if (ScriptManager1.IsInAsyncPostBack)if (ScriptManager1.AsyncPostBackSourceElementID == yourControl.ID){ // do your thang }

Awesome, thanks!

Ben.

Catch a Sys.WebForms.PageRequestManagerServerErrorException that occurs when server is dow

Hello,

I have an ajax timer control that updates an update panel every couple of seconds. When/if the server is down, there is an error message in a popup that says

"Sys.WebForms.PageRequestManagerServerErrorException: An unknown error ocurred while processing the request
on the server. The status code reutrned from the server was: 12029"

Basically I want to be able to catch this exception so that the popup does not continue to occur.

Is this possible?

Thanks in advance.

Take a look at the following posts on my blog:

http://fredrik.nsquared2.com/viewpost.aspx?PostID=395&showfeedback=true

http://fredrik.nsquared2.com/viewpost.aspx?PostID=394&showfeedback=true

You can also use the PageRequestManager, for example (This code should be located on the client):

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
function EndRequestHandler(sender, args)
{
if (args.get_error() != undefined)
{
var errorMessage;
if (args.get_response().get_statusCode() == '200')
{
errorMessage = args.get_error().message;
}
else
{
errorMessage = 'An unspecified error occurred. ';
}
args.set_errorHandled(true);
alert(errorMessage);
}
}


That's just what I needed. Thank you.