What is the best way to handle multiple popup dialogs in ASP.Net Web Application? Trying I have approx 5+ popup dialogs to show in the main page. currently I am using the ModalPopUpExtender to display the first popup. Do I have to Create a (New Panel and ModalPopUpExtender) for every popup? All this code in the main page would make it very cluttered.
How about having a user control with one modalpopupextender exposing a public enum property to set the type of the popup. You can have 5 panels inside that modalpopupextender whose display/data are controlled by the enum property.
From the main page, you set the enum property before you call usercontrol.show() which will in turn call mpe.Show(); after setting the visibility on the appropriate panel.
This way you will only have one user control on the main page and all the pop up logic is contained within it.
Related
I have three views inside a Multiview
How to activate one by one view means I Just want to change the Active View Index of the Multiview using javascript in ClientSide How can i do this?
I dont think you will be able to without causing a post back as the multiview is a server side control and only the active view is rendered to the browser.
You probably need to have all the views on the page and all but one hidden. Are you implementing some time of tab control?
There is a tab control in the ajax control toolkit which switches between views clientside:
http://www.asp.net/ajax/ajaxcontroltoolkit/Samples/Tabs/Tabs.aspx
I have a ASP.net page with couple of tabpanels. When a user hits submit button when he is on the First tab I am showing the user the second tab control. Ontabindexchanged I am dynamically creating a usercontrol and passing some values to the control.
Now when the user is in the 2nd tab and if he navigates to the first tab, I need to pass some values to the first tab.
At the tabcontainer level how do I pass values between tabs?
I think what your problem is, you need to maintain viewstate of your dynamically created controls, otherwise there is no problem to pass values between tabs. like..
tab1TextBox1.text=tab2Textbox2.text (Since your controls are in AJAX tab panel, no need to find control from tab panel)
For Maintaining viewstate of your dynamically created user control, you need to create your control in page_init() event.
I want to create a reusable user control which contains a date time picker in asp.net. Need to add this user control in a grid view as column.While clicking the column,date time picker has to be displayed.Which is the suitable method,Creating the component or creating the user control.Also want to know,How to add this component in to the toolbox?
The main difference between a component and a control is that a component has no UI... so clearly it is a control that you want as there must be a user interface portion for a date picker.
As for getting your control into the toolbox, right click it and there is an option to add item(s) which presents a browse dialog allowing you to locate the assembly containing your control.
You can drag and drop UserControls without them being in the tool box. When you're in design mode for an .aspx or .ascx page, you can drag and drop the UserControl from the Solution Explorer (by just selecting the file and dragging it).
I have two aspx pages i.e. default1.aspx and default2.aspx. Default1 contains some controls, tables etc. I am showing Default2.aspx into anthor window using hyperlink, setting its target to _blank. What I need is to call a button event which is placed inside Default1.aspx as soon as Default2 is closed (i.e. as soon as the new window showing default2 is closed).
Although, I know that this can be accomplished by showing the default2 into a modal popup i.e. show the default2 into a modal dialog and after that call the button event using javascript. But due to some reasons i am not permitted to do that.
Could some one please show me how i could do that.
If I was you, I'd refactor what will the button in page 1 do in a helper method that both of pages can call.
I have a ListView on a page that displays a list of widgets. When a user clicks on one of the items in the list, I want to display a ModalPopup that contains controls allowing the user to operate on the item they selected.
I could easily accomplish this by placing a Panel and a ModalPopupExtender in the ListView's ItemTemplate, but this mean one set of hidden controls for each and every widget, which would massively bloat the page size. (There are going to be some rather heavyweight controls in there.) Instead I want to reuse a single ModalPopup for each of the widgets in the list.
I've done some searching but I haven't found anything that applies directly to my situation before. From what I've been able to figure out, however, I have to do something like this:
Place a Panel and a ModalPopupExtender on the page inside an UpdatePanel.
Build a custom WidgetManipulator user control that has a WidgetID property. Put this in the Panel, along with a couple OK/Cancel buttons.
In Javascript on the page, attach a click handler to each widget in the ListView that triggers a postback on the UpdatePanel.
On the UpdatePanel_Load event on the server, display the ModalPopup and then set the WidgetID propety on the WidgetManipulator to the ID of the clicked widget.
On the OKButton_Click event or CancelButton_Click event on the server, hide the ModalPopup. If OKButton was clicked, call WidgetManipulator.SaveChanges() first.
The part I haven't figured out is: How the heck do I know what widget was clicked on, and how do I pass that back to the server when I refresh the UpdatePanel? Is this even the right approach at all?
If you can use jQuery instead you could do something along the lines of these two posts:
Modal Delete Confirmation Version
Two Using jQuery SimpleModal Plugin
Demo
Inserting Content Using
jQuery SimpleModal Plugin Demo
When I need to pass data from client to server in ASP.NET AJAX, I generally use an asp:HiddenField with runat="server". Both can see it freely, but beware potential postback asynchronicity.
Sounds like you need to notify the server the widget was clicked - You may use a Timer to postback; or I'd go with option 5.