JQueryMobile dialog shows twice because of a postback - asp.net

I have an asp.net page with a timer embedded in an UpdatePanel (UpdateMode="Conditional", ChildrenAsTriggers="false"). The timer is responsible for updating some components of that page every few seconds.
There are also some HyperLink controls on the page and they open a JQueryMobile dialog when clicked (data-rel="dialog"). The problem is that the timer i mentioned causes postback every few seconds. So when a dialog is opened and then closed, the first such postback after then causes the dialog to open once again.
Using the rel="external" as another attribute of the HyperLinks I mentioned solves the problem, but this is no solution for me. This causes full redirection to the dialog page instead of showing it using AJAX (as if on top of current page).
My idea was to stop the timer when any hyperlink is clicked. This solves the problem, but I have no idea how to start the timer again when the dialog closes. Is it possible to detect when a JQueryMobile dialog is closed? I know, this sounds stupid, but I can't come up with a better idea. Will you help me, please?
So basically, I don't want the JQueryMobile dialog page to show up for the second time after a timer tick. Could you please advise me how to achieve that?

jQuery Mobile with asp.net Web Forms and an UpdatePannel? This just sounds like a horrible combination.
jQuery Mobile and Web Forms fundamentally don't work well together. The specific issue that Web Forms requires a single <form /> element that wraps all controls (and most content). jQuery Mobile attempts to build up the DOM with "virtual" pages via ajax loading. This breaks the PostBack model by submitting the entire form instead of the individual form found within each page template. Now throw UpdatePanels in there...
Your only hope is go exclusively with Single page templates and to disable all ajax loading data-ajax="false" on both links and forms. And just say no to UpdatePanels.
asp.net MVC would give you much greater control over these issues.

Related

disable button from submitting multiple time

I have created a visual webpart which means it has not form / body element in it. I have three submit buttons on the webpart. At one time, only one of there three button is visible. These button performs validation on multiple controls that are added on the webpart and then call server side methods.
Issue is that it takes time for webpart to submit and during this user can press submit button more than once which result is malfunction of the application.
I have tried jQuery solutions like adding disable attribute to submit button but it stops webpart from submitting as well.
Any help to stop multiple submit.
You can consider using Ajax for posting your form.
And, until some processing is going on server, disable UI & show a Loading Image.
Refer:
jQuery.ajax()
UpdatePanel Control Overview
UpdateProgress Control Overview

.net page design with complicated Ajax relationship

I am creating a .net website in c#.
The master page contains a fixed footer bar from which you can display 'bookmarks'. I also have a remove function for each bookmark.
Some aspx pages may have a add bookmark/remove bookmark function (a button control) on them.
I use update panels throughout so button controls are always encapsulated by one.
If I add/remove a bookmark from an aspx page, I can trigger an update to the fixed footer panel. A delegate event is triggered in the aspx page which calls a method on the master page to update the fixed footer panel, so everything is sync'd dynamically.
It doesn't seem possible to do the same the other way around. If i remove a bookmark from the fixed footer, I would need to know if the current aspx page was displaying a bookmark control. Pretty much impossible I would have thought, but I'm open to suggestions.
With that in mind the question really is does anyone have a technique that they use to deal with these scenarios, such as calling a full page update or something similar, or is it a case of doing nothing until the next page load/postback?
Thanks in advance.

Open aspx page in modal popup

I have an aspx page (let say page1.aspx) having labels and buttons on it. In some other page i need to show content of page1.aspx in modal popup. I have read many articles, but did't find exact solution. Some of the possible ideas are, 1: create Usercontrol, 2: Use Server.execute() method.
Please suggest any solution. Thanks
If you simply want to show a popup (a modal dialog) you can create an user control which contains the markup form page1.aspx and use either AjaxControlTookit (ModalPopup) or jQuery.dialog
I prefer the jQuery.Dialog, it saves 2 postbacks to the server and is easier to integrate.
Here is how to integrate it with ASP .Net, a little trick so the inputs inside that dialog will be posted to server, when the button is clicked.

external page/control in jquery dialog

I'm building an web application using Asp.Net, How I can load other page or control ( like login or feedback form) in dialog and make sure postback events of that control/page execute successfully.
Take a look at jQuery WoWWindow.
After trying out various JQuery plugins, I finally choose popup extender of Asp.Net Ajax control toolkit.
The problem that I was facing with JQuery plugins, they do not handle postpack event properly. JQuery UI dialog is the closest match to my requirement, I will try it again next time.

Click event for textbox

There is one column of textbox in my item template. When I run the page and click on the textbox I want an event to fire. How can I make this happen?
What do you want to do when someone clicks? Odds are it's something you'd be best off processing on the client in JavaScript, possibly using jQuery. JavaScript will happily handle a "textbox" click event, although by the time your textbox hits the browser it's been rendered as an <input type="text">.
Think of ASP.Net as being a tool that generates and manipulates HTML, and sends it to/from the browser. ASP.Net events are the result of the browser posting the entire page back to the server, the server doing something to it, and the server sending the whole page back. There's obviously times when that is what you'd want, and times when it's not, I suspect this will be the latter, unless you're doing something data related.
To show a div on textbox click, I would use the jQuery Show() and Hide() methods. Create your content in ASP.net, and use 1 jQuery function to hide the div when the page loads (on browser, not server), and another to show them. Have a look at these - http://api.jquery.com/show/ and http://api.jquery.com/hide/ . The examples on that page will translate to what you're after; don't let the ASP.Net thing distract you, by the time your page is on the browser it's in HTML.

Resources