Solved

dopostbak event

Posted on 2006-07-13
4
412 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
  • 2
  • 2
4 Comments
 
LVL 9

Expert Comment

by:jonorossi
Comment Utility
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
Comment Utility
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 500 total points
Comment Utility
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
Comment Utility
ok, will give it a shot!!! cheers!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now