Pertinent comments on several modal popup posts on here.

Last post 04-17-2008 3:18 PM by BGriffin_TPA. 1 replies.

Sort Posts:

  • Pertinent comments on several modal popup posts on here.

    04-17-2008, 1:04 PM

    Here is the most recent:

    http://forums.asp.net/t/1249093.aspx

    This is an excerpt of a response to this artice:

    http://mattberseth.com/blog/2007/07/confirm_gridview_deletes_with.html

    It was good, but every article on this subject has been simplistic of the
    real world of windows (& now web) development I've been doing for many
    years. I've spent weeks of my time experimenting to find the full range of
    capabilities of AJAX modal popups and what I've found:

    Ex 1 : Extender-->button-->Panel

    (1) The Atlas modal popup works fine when invoked from a click event on a button.
    No postback.

    (2) When invoked from any other control (than the 1 the extender is tied to )
    by using .Show ??..it doesn't work (causes a postback)..invariably.

    This happens when the code behind for an event requires conditional invocation:

    Grid_SelectedIndexChanged()
         If somecondition then
               (do stuff)
         else
               extender.Show
         endif
    end sub

    Doesn't matter if the "other" control is a postback(asp) or callback(anthem)...
    .Show doesn't work (causes a postback, or nothing )..try it..
    markup and codebehind are attached.

    If I tie a separate extender to each control that needs to invoke that popup,
    (I did that) in order to get it to "fire"..it does..unconditionally.. wheather I
    wanted it to or not..see the IF statement.

    If a callback(anthem) control is tied to the extender as example 1 above..
    it also works..demonstrating that the extender supports callbacks, just not its
    own .Show method..the line executes, break points show that, but returns neither
    error or a successful rendering.

    I'd like to see an article on a real world example where some set of the methods
    of the extender are demonstrated like the example above, in a real context that
    developers would be needing them. My search was for an if statement in the
    Grid_SelectedIndexChanged() event that would do a .Show (or not) based on some
    criteria. If I have to go to the pre render event and if statement there, its not best, but
    acceptable..but..how would you abort the render at that point?

    1) where does .Show work w/o a postback?
    2) can any control not tied to the extender cause a render to happen (w/o a postback)?
    3) I have an example where the popup happens and I close it, but when I click the button again...nothing.

    Here is the actual source from the browser:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html   xmlns="http://www.w3.org/1999/xhtml" >
    <head id="Head1"><meta content="text/VBScript" http-equiv="content-script-type" /><link REL="stylesheet" TYPE="text/css" href="Stylesheet.css" /><title>ABC</title></head>

    <body onload="MM_preloadImages('~/Images/_NoSignals.bmp')" bottommargin="5" leftmargin="5" rightmargin="5" topmargin="10"
        style="left: 0.083in; position: absolute; z-index: 2; height: 0.25in; background-image: url(Images/Static/_BackGround.bmp); width: 0.791in;">
        <form name="form1" method="post" action="Default.aspx" id="form1">
    <div>
    <input type="hidden" name="ToolkitScriptManager1_HiddenField" id="ToolkitScriptManager1_HiddenField" value="" />
    <input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
    <input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
    <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTExNDE5NDUwMThkZBhW6Hc27ok8EGSsPngmxR5rI/zl" />
    </div>

    <script type="text/javascript">
    //<![CDATA[
    var theForm = document.forms['form1'];
    if (!theForm) {
        theForm = document.form1;
    }
    function __doPostBack(eventTarget, eventArgument) {
        if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
            theForm.__EVENTTARGET.value = eventTarget;
            theForm.__EVENTARGUMENT.value = eventArgument;
            theForm.submit();
        }
    }
    //]]>
    </script>


    <script src="/AJAXGridTest/WebResource.axd?d=K07dkoAwQ38TiiAVSoxK8w2&amp;t=633315183656297264" type="text/javascript"></script>


    <script src="/AJAXGridTest/ScriptResource.axd?d=lMarKtIznjIkIyNxiIDOO31kM3jBvSwEtlrqT3NLEzt50d5ON44wpbhqbzCXw4YMW4s5rtt0bSlYFsYUDSn2zXBWktGetTiePhTbyr8nwPQ1&amp;t=633085505856460128" type="text/javascript"></script>
    <script src="/AJAXGridTest/ScriptResource.axd?d=lMarKtIznjIkIyNxiIDOO31kM3jBvSwEtlrqT3NLEzt50d5ON44wpbhqbzCXw4YMW4s5rtt0bSlYFsYUDSn2zQV6l7SSGqC0fkFjFQMGLBTdufrnKiZDbokwWA-Yn8s40&amp;t=633085505856460128" type="text/javascript"></script>
    <script src="/AJAXGridTest/Default.aspx?_TSM_HiddenField_=ToolkitScriptManager1_HiddenField&amp;_TSM_CombinedScripts_=%3b%3bAjaxControlToolkit%2c+Version%3d1.0.20229.20821%2c+Culture%3dneutral%2c+PublicKeyToken%3d28f01b0e84b6d53e%3aen-US%3ac5c982cc-4942-4683-9b48-c2c58277700f%3ae2e86ef9%3a1df13a87%3a3858419b%3a9ea3f0e2%3a96741c43%3ac4c00916%3ac7c04611%3acd120801%3a38ec41c0" type="text/javascript"></script>
            <script type="text/javascript">
    //<![CDATA[
    Sys.WebForms.PageRequestManager._initialize('ToolkitScriptManager1', document.getElementById('form1'));
    Sys.WebForms.PageRequestManager.getInstance()._updateControls([], [], [], 90);
    //]]>
    </script>

           
           
            &nbsp;       
            &nbsp; &nbsp;<!-- BuyIt Message Box -->
            <div id="MsgBoxBuyIt" class="blackborder" onkeypress="javascript:return WebForm_FireDefaultButton(event, 'cmdCancelBuy')" style="color:Yellow;background-color:WhiteSmoke;border-color:Black;border-width:1px;border-style:Solid;height:80px;width:344px;background: gainsboro; display:none; left: 232px; position: absolute; top: 320px; z-index: 132; text-align: center;">
     
                <input type="submit" name="cmdCancelBuy" value="" id="cmdCancelBuy" style="height:22px;width:134px;left: 192px; position: absolute; top: 32px" />
                <input type="submit" name="cmdBuy" value="" onclick="();" id="cmdBuy" style="height:22px;width:134px;left: 16px;position: absolute; top: 32px" />
            
    </div>
            &nbsp; &nbsp;
            <a id="ASPLink" href="javascript:__doPostBack('ASPLink','')" style="display:inline-block;width:176px;left: 32px; position: absolute; top: 200px">ASP-uses show-Causes PB</a>
           <input type="submit" name="Anthem" value="Anthem-tied to extender2-No PB" id="Anthem" style="width:208px;left: 32px; position: absolute; top: 224px" />
            <input type="submit" name="Button1" value="ASP-tied to extender1-No PB" id="Button1" style="left: 32px; position: absolute; top: 168px" />
           
       
    <div>

     <input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWBgK/z5WJDwK16Pi+DgK+isj1AwLztI65DQK4gIfNAQKM54rGBrRelBrzEfu7pnQae3q+3ueIMtbq" />
    </div>

    <script type="text/javascript">
    //<![CDATA[
    Sys.Application.initialize();
    Sys.Application.add_init(function() {
        $create(AjaxControlToolkit.ModalPopupBehavior, {"CancelControlID":"cmdCancelBuy","OkControlID":"cmdBuy","PopupControlID":"MsgBoxBuyIt","dynamicServicePath":"/AJAXGridTest/Default.aspx","id":"ModalPopupExtender1"}, null, null, $get("Button1"));
    });
    Sys.Application.add_init(function() {
        $create(AjaxControlToolkit.ModalPopupBehavior, {"PopupControlID":"MsgBoxBuyIt","dynamicServicePath":"/AJAXGridTest/Default.aspx","id":"ModalPopupExtender2"}, null, null, $get("Anthem"));
    });
    //]]>
    </script>
    </form>
    </body>
    </html>

    and here is the code behind:

    Imports System.Web
    Imports System.Web.UI
    Imports System.Web.UI.WebControls

    Partial Class _Default
        Inherits System.Web.UI.Page

        Protected Sub ASPLink_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ASPLink.Click
            ModalPopupExtender1.Show()

        End Sub

        Protected Sub cmdBuy_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdBuy.Click

        End Sub

        Protected Sub cmdCancelBuy_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdCancelBuy.Click

        End Sub

        Protected Sub MsgBoxBuyIt_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles MsgBoxBuyIt.PreRender
            Dim x As String
        End Sub

    End Class

  • Re: Pertinent comments on several modal popup posts on here.

    04-17-2008, 3:18 PM
    Answer

    Looks like I found it in a form that I could make sense of :

    http://msdn2.microsoft.com/en-us/magazine/cc164247.aspx

    This subject matter is so arcane for someone coming from a winforms

    environment, with panels inside of panels and fake controls all to

    get a popup box with the behavior you want. if I can help anybody else

    having these kinda problems, the least I can do is assist.  Yes

    As for the link, you wont be able to match his objectdatasource, but

    ignore that, just delete it. The entire idea of popup navigation is there

    in a "page behind" not just "single page" model, also a source of

    challenge for winforms people. Please disregard 1st post.

    Regards.. Cool

Page 1 of 1 (2 items)