Solved

dopostbak event

Posted on 2006-07-13
4
419 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 500 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
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…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

630 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