Q:

Jquery UI Dialog with asp button trigger in update panel

I have a issue with Jquery Modal dialog being called from a button inside an update panel..
here are the insights..
Javascript used for opening a Jquery modal dialog in aspx page..
<script type='text/javascript'>
    function openModalDiv(divname) {
        $('#' + divname).dialog({ 
            autoOpen: false, 
            bgiframe: true, 
            closeOnEscape: true, 
            modal: true, 
            resizable: false, 
            height: 'auto', 
            buttons: { Ok: function () { closeModalDiv(divname) } },
            open: function (event, ui) { jQuery('.ui-dialog-titlebar-close').hide(); }
        });
        $('#' + divname).dialog('open');
        ('#' + divname).parent().appendTo($('form:FrmSearch'));
        $('#' + divname).css('overflow', 'hidden')
    }

    function closeModalDiv(divname) {
        $('#' + divname).dialog('close');
    }
</script>

the button in aspx page..
<asp:UpdatePanel ID="upDialogs" runat="server">
    <ContentTemplate>
        <asp:Button ID="btnOpenDialog" runat="server" Text="Open Dialog" onclick="btnOpenDialog_Click" />
    </ContentTemplate>
</asp:UpdatePanel>

The Div which needs to be called from code behind via javascript..
<div id="ErrorDiv2" title="Error" style="visibility:hidden">
    <p><span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px 0;"></span>Please select an option among the results and try again!</p>
</div>

Finally the code behind ..
protected void btnOpenDialog_Click(object sender, EventArgs e)
{
    if (ProfileID == null)
    {
        Page.ClientScript.RegisterStartupScript(this.GetType(), "ErrorDivOpen", "document.getElementById('ErrorDiv2').style.visibility = 'visible';", true);
        Page.ClientScript.RegisterStartupScript(this.GetType(), "ErrorDivShow", "openModalDiv('ErrorDiv2');", true);  
    }
}

Now the Issue in detail..
Without the update panel the modal dialog pops very fine but makes full post back..
I want to have only a partial post back and hence am using a update panel..
The following are the solutions I have tried..

Added update panel to the existing div, dint work.
added an update panel along with runat="Server" for the div, still dint work..

Can any one help me with possible solutions?

A:

Thanks for your quick reply but I found another solution.
I added both update panel and runat parameters to the Div.
<asp:UpdatePanel ID="upErrorDiv" runat="server"><ContentTemplate>
    <div runat="server" id="ErrorDiv2" title="Error" style="visibility:hidden">
        <p><span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px 0;"></span>Please select an option among the results and try again!</p>
    </div>
</ContentTemplate></asp:UpdatePanel>

Changed the code behind as.
if (ProfileID == null)
{
    ScriptManager.RegisterStartupScript(ErrorDiv2,this.GetType(), "ErrorDivOpen", "document.getElementById('ErrorDiv2').style.visibility = 'visible';", true);
    ScriptManager.RegisterStartupScript(ErrorDiv2,this.GetType(), "ErrorDivShow", "openModalDiv('ErrorDiv2');", true);  
    return;
}

