locked
Page._doPostBack RRS feed

  • Question

  • User-1826049516 posted

    Hi,

    I am using this to initiate partial post back from some links. When somebody presses one of these links, I'm using Page.add_beginRequest and Page.add_endRequest to show a progress bar. To make this work, I have a ASP LinkButton server control which is a trigger for the update panel, and I'm triggering the post back by referencing this LinkButton in the Page._doPostBack command. This line is in the jQuery event handlers for my links. 

    Page._doPostBack( 'ctl00$header$Search_Button', '' );

    And this is the beginRequest and endRequest:

    function beginRequest( sender, args )
    {
    
    	var img = $( "#Search_Button" ).children( "img" );
    	img.prop( "src", "/images/progress-blue.gif" );
    	$( "#recentSrchs" ).hide();
    	
    }
    
    function endRequest( sender, args )
    {
    
    	var img = $( "#Search_Button" ).children( "img" );
    	img.prop( "src", "/images/search.png" );
    	$( "#recentSrchs" ).hide();
    	
    }

    So the only image that changes is the main search button one. What I want to do is pass the clicked element to the beginRequest and endRequest functions and change the images for the relevant (clicked). Is this possible? My links are standard, client side anchors. They are not server controls set as tirggers for the update panel.

    Thanks

    Sunday, September 2, 2018 12:51 PM

Answers

  • User1724605321 posted

    Hi ldoodle ,

    When clicking the links , you could save the click item on page hidden field , and read the value in related JS function . But i would suggest you could use Ajax to call server side function which may make your code clearly .

    Best Regards,

    Nan Yu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 6, 2018 7:08 AM

All replies

  • User1724605321 posted

    Hi Idoodle,

    ne. What I want to do is pass the clicked element to the beginRequest and endRequest functions and change the images for the relevant (clicked).

    In beginRequest function , you can get the postback element's id by :

     var postbackElement = args.get_postBackElement();
     var id = postbackElement.name;

    You can then store the id in a hidden field in the page and read the value from hidden field in endRequest function .

    Best Regards,

    Nan Yu

    Monday, September 3, 2018 5:34 AM
  • User-1826049516 posted

    Thanks Nan Yu.

    I don't think this will work. As my pure HTML links are triggering the only ASP.NET LinkButton control (which is the one that does the postback), this method will always return the LinkButton as the PostBackElement.

    HTML Link 1 > LinkButton > Postback
    HTML Link 2 > LinkButton > Postback

    Tuesday, September 4, 2018 2:45 PM
  • User1724605321 posted

    Hi ldoodle ,

    When clicking the links , you could save the click item on page hidden field , and read the value in related JS function . But i would suggest you could use Ajax to call server side function which may make your code clearly .

    Best Regards,

    Nan Yu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 6, 2018 7:08 AM