AJAX :: Run A JS Function Before The Modal Popup Closes
Dec 8, 2010
I need to run a JS function before the modal popup closes, this is because I need to close a flash netstream, currently the flv continues to play after modal is closed, you can hear audio and stream continues to download. I have the code to deal with this, but the modal closes before JS is actioned. The JS below talks to swf (videoPlayer_low) and closes the netstream. Note all this pain is to deal with IE :(
I have a modal popup that on the first time it is running, if the user clicks the greyed out background the modal closes. On the 2nd and later times it runs correctly. The user can click the background and it works correctly. I have searched around and tried a few things with out any luck.
Here is the code.
<telerik:RadScriptManager ID="RadScriptManager1" runat="server" EnablePageMethods="true" EnablePartialRendering="true"> </telerik:RadScriptManager> <ajax:ModalPopupExtender ID="GlobalModalPopupExtender" runat="server" PopupControlID="GlobalpnlPopup" TargetControlID="GlobalMain" BackgroundCssClass="modal_background"> </ajax:ModalPopupExtender> <div id="GlobalMain" runat="server"> </div> <asp:Panel ID="GlobalpnlPopup" runat="server" Style="display: none; background-color: White; border-width: 4px; border-style: solid; border-color: #EA0A8D; padding: 4px; height: 40px; width: 200px; z-index: 10000; " CssClass="RadButton"> <table align="center"> <tr> <td align="center"> <asp:Image ID="imgGlobalProcessing" CssClass="progress_image" runat="server" ImageUrl="~/images/ajax-loader.gif" /> <b>Processing...</b> </td> </tr> </table> </asp:Panel> <script type="text/javascript"> Sys.Application.add_load(GlobalApplicationLoadHandler); function GlobalApplicationLoadHandler(sender, args) { var prm = Sys.WebForms.PageRequestManager.getInstance(); if (!prm.get_isInAsyncPostBack()) { prm.add_initializeRequest(initRequest); prm.add_endRequest(endRequest); } } function timer() { return true; } function initRequest(sender, args) { var pop = $find("<%=GlobalModalPopupExtender.ClientID%>"); pop.show(); } function endRequest(sender, args) { var pop = $find("<%=GlobalModalPopupExtender.ClientID%>"); pop.hide(); } </script> .modal_background { background-color:Gray; filter:alpha(opacity=65); -moz-opacity:0.65; /* It is for Mozilla firefox browser */ Opacity:0.65; }
I need to set focus on a textbox in parent form after the pop extender closes. I am setting the focus before showing the popup, but when the popup closes, it is lost.
I have a treeview and a button inside a panel. On a click of button 'btnView' i want to show the panel. So i decided to use the ajax modal popup. Every thing is fine but mu popup closes on selecting a node in the treeview. Actually i want to close the popup on click of button 'btnOK'. Here is my page markup
I am trying to get a modal popup inside a modal popup?, also i want to fire the modal popup on a condition in a text change event of a textbox?...is this possible and can anyone give me directon on this
I have an Ajax ModalPopupExtender on a page. To summarise. I have a link on a page, when I click the link the modal popup displays. On this modalpopup I've a textbox and an 'ok' and 'cancel' button. I wish to find out what was entered in the textbox when the button is clicked I try this but the value of ((TextBox)button1.Page.FindControl("theTitle")) is null.
if (((TextBox)button1.Page.FindControl("theTitle")).Text == "") void okButton_Click(object sender, EventArgs e) { try { //if i try this tt does not compile//The name 'theTitle' does not exist in the current context//if(theTitle.Text == "")//{//} Button button1 = (Button)sender; //TextBox theTitle = ((ImageButton)(e.Item.FindControl("theTitle"))); if (((TextBox)button1.Page.FindControl("theTitle")).Text == "") { } else { } } catch (Exception) { } }
I have three modal popup and three link buttons the first link button is on menu i.e. login that shows login-popup and the login popup contains two links forgot password and register both of them opens a popup but the problem is the login popup isnt hiding with click on register or foreget link the popups are appearing perfectly but arent hiding.
I also used breakpoints on link click event and are not going to code behind file on click and popup is just shown without hiding the other. And the css used is I found on aspsnippet site!
I have a popup with a form on it displaying account details for clients. Each client has at least 1 account but may have up to 999. The popup and form is displayed properly, but when i click on any of the < > << >> pager options, the popup closes instead of moving to the next record in the form.
I have a AsyncFileUpload control on a greybox popup. There are some processing that happens, and then closes the popup registering javascript as a button click event fires.
If i upload a file with the AsyncFileUpload popup page redirects to itself instead of the parent page. It redirects to the parent page as it supposed to if I dont upload a file using AsyncFileUpload. Another thing I have noticed is if I upload a file using AsyncFileUpload popup gets closed and redirects to self on any button click even without the close script call.
I have a AsyncFileUpload control on a greybox popup. There are some processing that happens, and then closes the popup registering javascript as a button click event fires.
If i upload a file with the AsyncFileUpload popup page redirects to itself instead of the parent page. It redirects to the parent page as it supposed to if I dont upload a file using AsyncFileUpload. Another thing I have noticed is if I upload a file using AsyncFileUpload popup gets closed and redirects to self on any button click even without the close script call.
Modal Popup user control (its a message box) on top of a modal popup with javascript that maintains postback on a scrollable div all inside of an update panel causes my page to flash on postback of the user control. If any one of the peices (user control, modal popup, javascript) are missing everything works fine. The javascript is maintaing scrollback on a scrollable listview on the page. A modalpopup is shown on top of this main page that is for report parameters. The user control is used for validation and is displayed if a parameter is invalid. I know this may not be the best design, but it can't really change unless its a minor change. Heres the js if anyone wants to see popup or styles let me know.
//Begin methods to maintain or reset scroll position during postback. var controlIds = []; var scrollTops = []; //Register a control to maintain its scroll position on postbacks. function MaintainPostback(controlId) { controlIds.push(controlId); } //Find the div/control id in the controlIds array and set its scroll position to 0. function ResetControlScrollTop(controlId) { var index = 0; while (index < controlIds.length) { if (controlId == controlIds[index]) { scrollTops[index] = 0; return; } index++; } }............
I can open the modalpopup, can close the popup, but if i click the "edit" button to edit any of rows, the popup closes automatically. If I click again, the "Update" and "Cancel" buttons shows, and after clicking one of those, popup closes again. The above code works, if i use gridview the insert, edit or delete the data, does not close automatically. What may be the cause of this problem.
I'm using modal popup extender and panel with calendar in it. Click the "Next / Previous Month" closes the modal popup. How do I tell the modal popup to ignore click events in a calendar control inside the panel targeted for popup? I'm confused because when using extender before, you had to click OkButton or Cancel to close popup. I have update panel for reason. I just minimized the code for easy review.
I have one page with a panel that makes up my ModalPopup. On the ModalPopup there is an updatepanel with a textbox and a button in it. There is a textbox on the "parent" page and I want to click the button on the modalpopup and move the data from the popup textbox to the parent textbox. So far, no joy. I have a line in the code behind to move the data between textboxes and I have also tried javascript to do the same thing but I am not able to make this happen unless i click the button twice.
How can I get one modal popup to trigger a second modal? And in between each modal, I need to execute server code.
Page load, check if question needs answering -> Modal 1 -> User answers -> run server code to check if question two needs answering -> Modal 2 -> show page.
I could do this using a series of asp:Views if there is not a clean way, the management just really likes the modals
In my application I have a formview which is inside of a Ajax modal popup.Once users enter the information in the formview and click save, I validation the input.errors, I want to display an error message as a popup or as a modal popup (not javascript alert) with in the ajax modal.How do I do that. I tried several ways but it closes the ajax modal popup.
I'm in a Unique position where I have to display one popup above another popup. Problem is that popup B's background does not show above popup A's content and as such you ae still able to click on buttons, ect. on popup A.
I tried to rather disable the Tab Control on popup A with javascript once popup B is displayed, but it only disables textboxes and labels and nothing else.
getting popup B's background to display above popup A or help with disabling all controls (Contained in Tab Control) on popup A?
When using a modal popup extender along with an embedded video, the popup is hidden behind the video in IE but works as expected in FF.I've tried manually setting the z-index of the popup to a huge number and the z-index of the video object to 1 but this makes no difference. I've put the code for a sample page below.
public partial class AjaxUC : System.Web.UI.UserControl { private ITemplate _content = null; [TemplateInstance(TemplateInstance.Single)] [TemplateContainer(typeof(Container))] [PersistenceMode(PersistenceMode.InnerProperty)] public ITemplate Content { get { return _content; } set { _content = value; } } void Page_Init() { if (_content != null) { Container container = new Container(); _content.InstantiateIn(container); divContent.Controls.Add(container); lblSearchTitle.Text = LblModalSearchText; } } protected void Page_Load(object sender, EventArgs e) { if (hdVisible.Value=="true") { modalSearch.Show(); } } } public class Container : Control, INamingContainer { internal Container() { } }} This control when used on any aspx page will popup the control placed inside the template "divContent" as modalpopup. ________________________________________________________________________ Now I am trying to convert this user control to Custom Control and my code is:-
[ParseChildren(true)] [PersistChildren(true)] public class DNAWebAjaxTool : PlaceHolder { public event EventHandler BtnModalSearchCloseClickEvent; public event EventHandler Click; private ITemplate _content = null; private HtmlInputHidden _hdVisible; private Panel _pnlModalSearchContent; private Panel _pnlModalSearch; private ModalPopupExtender _modalSearch; private Button _btn; private DivContainer divContent = new DivContainer(); private string _viewState; public DNAWebAjaxTool() { } public Panel PnlModalSearchContent { get { if (_pnlModalSearchContent == null) { _pnlModalSearchContent = new Panel(); } return _pnlModalSearchContent; } } public ModalPopupExtender ModalSearch { get { if (_modalSearch == null) { _modalSearch = new ModalPopupExtender(); } return _modalSearch; } } public string ViewState { get { return _viewState; } set { _viewState = value; } } public HtmlInputHidden HdVisible { get { if (_hdVisible == null) { _hdVisible = new HtmlInputHidden(); } return _hdVisible; } } [TemplateInstance(TemplateInstance.Single)] [TemplateContainer(typeof(DivContainer))] [PersistenceMode(PersistenceMode.InnerProperty)] public ITemplate Content { get { return _content; } set { _content = value; } } protected override void OnInit(EventArgs e) { _content.InstantiateIn(divContent); base.Controls.Add(divContent); base.OnInit(e); } protected override void OnLoad(EventArgs e) { if (HdVisible.Value == "true") { ModalSearch.Show(); } base.OnLoad(e); } void _btn_Click(object sender, EventArgs e) { BtnModalSearchCloseClickEvent(sender, e); } public virtual void Hide() { PnlModalSearchContent.Visible = false; ModalSearch.Hide(); ViewState = "false"; } public virtual void Show() { PnlModalSearchContent.Visible = true; ModalSearch.Show(); ViewState = "true"; } protected override void CreateChildControls() { base.CreateChildControls(); } protected override void Render(HtmlTextWriter writer) { if (ViewState == "true") { _modalSearch = new ModalPopupExtender(); _modalSearch.ID = "modalSearch"; _modalSearch.TargetControlID = "btnHiddenSearch"; _modalSearch.PopupControlID = "pnlModalSearch"; _modalSearch.DropShadow = false; _modalSearch.RepositionMode = AjaxControlToolkit.ModalPopupRepositionMode.RepositionOnWindowResize; _modalSearch.Drag = false; _modalSearch.BackgroundCssClass = "modalBackground"; _modalSearch.Show(); _btn = new Button(); _btn.ID = "btnHiddenSearch"; _btn.Style.Value = "display: none"; _btn.RenderControl(writer); _pnlModalSearch = new Panel(); _pnlModalSearch.ID = "pnlModalSearch"; _pnlModalSearch.CssClass = "modalPopup"; _pnlModalSearch.RenderControl(writer); PnlModalSearchContent.ID = "pnlModalSearchContent"; PnlModalSearchContent.RenderControl(writer); divContent.RenderControl(writer); _btn = new Button(); _btn.ID = "btnModalSearchClose"; _btn.Text = "Close"; _btn.CausesValidation = false; _btn.Click += new EventHandler(_btn_Click); _btn.RenderControl(writer); } } } public class DivContainer : Control, INamingContainer { internal DivContainer() { } } ________________________________________________________________________________________________ The problem I am facing is that the modalpopup extennder is not coming up as a popup.
I have scriptmanager on master page and on content page I have update panel inside tabcontainer.
In update panel I have gridview. I have added modal popup to Delete linkbutton. When Item is deleted I give confirmation that item is deleted. When this alert pops up, again modal popup pops up. I have 4 tab panels in tab container and 3 of it have update panel with gridview. This is happening on each tab panel.
Earlier I was using scriptmanager on content page. Then I realised that I'm adding scriptmanager to every content page, so I placed it in master page.