Solved

dopostbak event

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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to repeat the data 4 43
Problem to copy file 14 92
global Variable - 2 functions in powershell 1 44
C#line chart with data on Y and time on X-axis 3 33
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
Suggested Courses

752 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