I am doing option 1 now, it is very lightweight, and all you need is ajax post (jQuery or UpdatePanel) and some modal ones (I use jQery user interface). This is simpler than a full page post, plus you have the added advantage that you can manipulate the page you are in as part of the result.
For example, I have grids on the page, the editor is modal, usually with more details, when you click "Save", the grid is updated. I put this in a universal template solution, and itβs very easy to work with, and it is as light as web forms that can be in this situation, so Iβm all in favor of option 1.
Here's an example approach that has your modal control inherited from UpdatePanel (code compressed for brevity):
public class Modal : UpdatePanel { private bool? _show; public string Title { get { return ViewState.Get("Title", string.Empty); } set { ViewState.Set("Title", value); } } public string SaveButtonText { get { return ViewState.Get("SaveButtonText", "Save"); } set { ViewState.Set("SaveButtonText", value); } } protected override void OnPreRender(EventArgs e) { if (_show.HasValue) RegScript(_show.Value); base.OnPreRender(e); } public new Modal Update() { base.Update();return this;} public Modal Show() { _show = true; return this; } public Modal Hide() { _show = false; return this; } private void RegScript(bool show) { const string scriptShow = "$(function() {{ modal('{0}','{1}','{2}'); }});"; ScriptManager.RegisterStartupScript(this, typeof (Modal), ClientID + (show ? "s" : "h"), string.Format(scriptShow, ClientID, Title, SaveButtonText), true); } }
In javascript:
function modal(id, mTitle, saveText) { var btns = {}; btns[saveText || "Save"] = function() { $(this).find("input[id$=MySaveButton]").click(); }; btns.Close = function() { $(this).dialog("close"); }; return $("#" + id).dialog('destroy').dialog({ title: mTitle, modal: true, width: (width || '650') + 'px', resizable: false, buttons: btns }).parent().appendTo($("form:first")); }
Then in your markup (now I canβt think of a better name than MyControls, sorry!):
<MyControls:Modal ID="MyPanel" runat="server" UpdateMode="Conditional" Title="Details"> //Any Controls here, ListView, whatever <asp:Button ID="MySaveButton" runat="server" OnClick="DoSomething" /> </MyControls:Modal>
In your codebehind pages you can:
MyPanel.Update().Show();
Mark your approach, I will have a jQuery action that sets the input field and presses the button in modal mode, invoking the update panel for postback and in this code that loads data into any control in modal, just call MyPanel.Update.Show(); , and it will appear on the screen when the ajax request of the update panel appears.
The example above using jQuery UI will have 2 buttons on the modal, one to close and do nothing, one to save, click on MySaveButton inside the modal, and you can do whatever you want on the server by calling MyPanel.Hide() if successful, or put an error message in the panel, if the verification fails, just do not call MyModal.Hide() , and after the postback, it will remain with the user.