Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

dopostbak event

Posted on 2006-07-13
4
Medium Priority
?
420 Views
Last Modified: 2012-08-14
Hi All,

Is it possible to catch asp.net's do postback event in javascript?

I have the following code that opens and collapses a <div>;-

<script language="JavaScript" type="text/javascript">
  var openedObj = false;
  function toggleDisplay(id)
    {
    obj = document.getElementById(id);
    if (obj.style.display == "none")
    {
           if(openedObj) openedObj.style.display = "none";
           obj.style.display = "";
           openedObj = obj;
    }
    else
    {
          obj.style.display = "none";
    }
  }
</script>

But when a user is sorting or paging the Gridview within the <div>, I don't want the <div> ton collapse so I need to ensure that the above code is not executing if its a dopostback event, is this possible?
0
Comment
Question by:claracruz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 9

Expert Comment

by:jonorossi
ID: 17105850
The ASP.NET IsPostBack property tells you if there was a postback. A postback is defined as a request back to the server that uses the POST HTTP method. Client side JavaScript runs on the user's web browser and cannot interact with events that occur on the server. You however could look at using AJAX for sorting and paging of your gridview; one product you might have heard of is Microsoft Atlas which is very easy to achieve what you want with an UpdatePanel.

Hope that helps, Jono
0
 
LVL 4

Author Comment

by:claracruz
ID: 17106755
Atlas is not an option at th moment, I can't get my head around it and am pressed for time on this.

Is there a simple way of going about this in c#

in asp, I was able to use the GetXmlHttpObject, is this possible in asp.net, like so


      function setAccessoryOptions(locker_option_id)
      {
      var url="setaccessoryopt.asp?sid=" + Math.random() + "&o=" + locker_option_id
      //alert(url)
      xmlHttp=GetXmlHttpObject(stateChanged)
      xmlHttp.open("GET", url , false)
      xmlHttp.send(null)
      }

function stateChanged()
{
        if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
        {
              ///do stuff
         }

}

will it follow the same priciple,
0
 
LVL 9

Accepted Solution

by:
jonorossi earned 2000 total points
ID: 17106805
Atlas is one of the most simplest AJAX frameworks out there, it takes 2 seconds to throw an UpdatePanel around your current controls and it just works, you don't have to make web services and the likes (thats the other option with Atlas). You might want to take a look at one of the videos about Atlas at atlas.asp.net or on channel9.msdn.com

However, you can use the HttpXmlRequest object just like in ASP; this object runs on the clients web browser. The HttpXmlRequest is the core to AJAX and is what all AJAX frameworks use including Atlas.

Hope that helps
0
 
LVL 4

Author Comment

by:claracruz
ID: 17110731
ok, will give it a shot!!! cheers!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question