tags:

views:

38

answers:

2

Looking at the other dialog questions, mine seems to be the exact opposite to postback queries. I have a dialog box which opens when a button is clicked. all that is fine. I have attached the dialog to the form and posting to asp.net is fine too, but, my problem is when a postback occurs of course the dialog closes which I do not want to happen as the user may want to post via the dialog function several times. Basically the dialog connects to an asp process that creates a folder, the user may want to create several folders (for image upload) but postback causes the dialog to close, rather abruptly!, and I would rather the user dismissed the dialog when they have finished. Any ideas how I might achieve that? I'm using Jquery and Asp.net C#. I'm fairly new to both c# and Jq so am flummuxed. I've tried this lastly........... Thanks

protected void Page_Load(object sender, System.EventArgs e)
{

    if (IsPostBack)
    {
        Page.ClientScript.RegisterStartupScript(this.GetType(), "callme", "$('#opener').click(function(x)", true);

    }
}
A: 

You might want to consider using AJAX to post the data from the dialog box. Otherwise, you could check for Page.IsPostback and open the dialog if true.

You could trigger the .click() event on your #opener object on Postback:

<script type="text/javascript">

    $(function() {
        <% if (Page.IsPostback) { %>
            $('#opener').trigger('click');
        <% } %>
    });

</script>
XSaint32
Thanks.. That is what I am trying work out how to do, I can't work out the syntax I need in the page load to call the following
RayH1066
@RayH1066 - See my edited answer above.
XSaint32
+1  A: 

I'd suggest looking at using an AJAX post to call your 'Create Folder' function, that way you can separate the postback from the currently displayed page and maintain your state there.

Lazarus
yes I am aware.. I am looking to be given advise as to how to do that. I do know what I should do, it is the how that I am looking for help with .. Thanks anyway
RayH1066