Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > ASP.NET 4 General Discussion
|
ASP.NET 4 General Discussion For ASP.NET 4 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 13th, 2012, 07:32 PM
Authorized User
 
Join Date: Dec 2011
Posts: 39
Thanks: 9
Thanked 0 Times in 0 Posts
Default I want to refresh an <asp:updatepanel> using jQuery. Is this possible?

I am using FancyBox as recommended by Imar and it's pretty awesome.

The problem I am having is that I need to refresh an update panel when the fancybox iframe closes.

I searched the web and tried 3 different suggestions and none of seem to work.


Right now, I am just refreshing the entire parent page using the beforeClose event but as you can imagine, it's a very ugly process.

Here is my current code:

Code:
 $(document).ready(function () {
        $(".fancyBox").fancybox({
          'type': 'iframe',
          'width': 600,
          'height': 600,
          'minHeight': 600,
          'openEffect': 'none',
          'closeEffect': 'none',
          'beforeClose': function () {
            parent.location.reload(true); // reloads the parent page
          },
          helpers: {
            overlay: {    // overlay options
              speedIn: 300,
              speedOut: 300,
              css: {
                cursor: 'pointer',
                'background-color': 'Gray'
              },
              closeClick: true  // any click on the overlay closes iframe
            }
          }
        });
      });

Imar if you can help that would amazing.
 
Old June 14th, 2012, 03:07 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Searching Google for "refresh updatepanel JavaScript" return s a lot of useful stuff:

http://encosia.com/easily-refresh-an...ng-javascript/
http://www.4guysfromrolla.com/articles/033110-1.aspx

The second link even shows how to use FancyBox.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old June 14th, 2012, 12:27 PM
Authorized User
 
Join Date: Dec 2011
Posts: 39
Thanks: 9
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Imar View Post
Hi there,

Searching Google for "refresh updatepanel JavaScript" return s a lot of useful stuff:

http://encosia.com/easily-refresh-an...ng-javascript/
http://www.4guysfromrolla.com/articles/033110-1.aspx

The second link even shows how to use FancyBox.

Cheers,

Imar
Thanks. I had already searched the web and tried the hidden button hack and the getpostbackbyreference but they didn't seem to work some reason. They did require me to disable some kind of eventvalidation attribute in my web config so they must have been firing.

I must have been missing something else. The second link is very informative so I will make sure to follow it to the T.

Thanks again.
 
Old June 14th, 2012, 03:40 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

You're welcome, and good luck with implementing it....

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old June 14th, 2012, 05:36 PM
Authorized User
 
Join Date: Dec 2011
Posts: 39
Thanks: 9
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Imar View Post
You're welcome, and good luck with implementing it....

Imar
Well, after spending a significant amount of time messing around with their examples the only one that seems to work is the linkbutton hack and even then I had to actually go into the linkbutton's event handler and manually databind the listview to get it to refresh.

At first I thought it was the update panel's ID getting messed up but even after setting clientID mode to static like your book says, it still didn't register.

Oh, well at least it works now. That Javascript always gives me the hardest time.

I have been reading about JSON and I wonder of you use it and what your thoughts on when to use it instead of an update panel.

Thanks again.
 
Old June 14th, 2012, 06:16 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
I have been reading about JSON and I wonder of you use it and what your thoughts on when to use it instead of an update panel.
A great alternative. As explained in the book, the UpdatePanel carries quite a bit of overhead as the whole page still goes through its entire life-cycle.

Using web services (ASMX or WCF) together with a client side framework for interacting with them such as jQuery is a great alternative.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old June 14th, 2012, 06:27 PM
Authorized User
 
Join Date: Dec 2011
Posts: 39
Thanks: 9
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Imar View Post
A great alternative. As explained in the book, the UpdatePanel carries quite a bit of overhead as the whole page still goes through its entire life-cycle.

Using web services (ASMX or WCF) together with a client side framework for interacting with them such as jQuery is a great alternative.

Cheers,

Imar
I see. But if you are using mostly grids and listviews is it still worth it? I have yet to see an example on using JSON for a gridview or listview with full crud operations, just very small examples like updating a label.

How difficult would it be in those cases?
 
Old June 15th, 2012, 02:51 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
How difficult would it be in those cases?
To update an existing GridView would be pretty difficult because of all the state it manages.

If you go down the "services" route you need to choose a different type of architecture. You would then use stuff like template binding in jQuery. Here's an example: http://net.tutsplus.com/tutorials/ja...ting-and-ajax/ (not sure if the plugin mentioned there is still around; the link is just meant as an example to give you some idea of what you could so).

To see what you can do if you go all the way with client side binding and service calls, check out this Knockout presentation from Steven Sanderson: http://channel9.msdn.com/Events/Tech...therlands/2159 Cool, but quite complex stuff. Well worth watching, if only to see Steven present.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
IceThatJaw (June 15th, 2012)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Ch 8: <asp:image> inside <a> & ext.CSS (pg. 274) epc BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 1 July 12th, 2008 04:37 AM
Prblem while using <asp:updatepanel> rajatake ASP.NET 2.0 Professional 5 March 22nd, 2007 02:05 PM
a problem in book<<beginning asp.net using vb>> luoware ASP.NET 1.0 and 1.1 Basics 3 December 8th, 2003 09:32 PM
HELP HELP ODBC<->ASP <-> XML moon Wrox Book Feedback 1 November 9th, 2003 12:42 PM
<<ASP.NET Security>>,download files in chapter 8 alaix All Other Wrox Books 1 July 24th, 2003 10:29 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.