Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to prevent a page refresh while a dialog box is open?

Status
Not open for further replies.

PPettit

IS-IT--Management
Sep 13, 2003
511
US
I've got a page (ASP.Net) that refreshes every two minutes (currently using ASP timer control to call some subs that update a dataset and then bind the results to a gridview). On this page, a user can click a linkbutton that causes a jQuery modal dialog box to popup. Everything works great, but when the refresh fires, the dialog box closes. Is there some way that I can start and stop the timer control based on the open and close events of the dialog box? I also tried putting the gridview in an updatepanel, but that prevented the dialog box from showing (not sure if it prevented the dialog completely or if it closed it instantaneously). My goal is to keep the dialog open (i.e prevent page refresh) until the dialog is closed by the user. Anyone have an idea on how to accomplish this?
 
What fires the refresh?

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
The timer control fires the refresh. I may be wrong, but I think it's actually the rebinding of the data to the grid that causes the page refresh.

I fixed my problem by fixing my way of thinking. I was trying to do everything with ASP.Net or with JavaScript. There may still be a way to do it with one technology, but my final solution uses a mix of both.

I set the refresh rate in the timer control (ASP). When the user clicks the linkbutton (ASP) to show the dialog, the interval value of the timer control is set to something like '999999999' (couldn't set it to zero for some reason). This prevents the refresh from firing. When the user closes the dialog box (JavaScript), its close event does a "window.location.href" back to the current page. This causes a page refresh and sets the timer value back to the regular interval.

For my current purposes, the works fine. If someone has a better solution, I'm interesting in knowing what it is.
 
ASP and ASP.net are server-side code so cannot trigger a client side refresh, it must either be writing a meta refresh to the document or creating a client site javascript that fires a timer, if it is a script your dialogue script needs to hook into that timer.


clicks the linkbutton (ASP)
The linkbutton is not ASP, certainly it may have been created by server side ASP, but ASP has not involved when it is 'clicked'.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top