views:

50

answers:

3

Hello. This is my jquery and javascript code :

<script type="text/javascript">
$(document).ready(function () {
    //setup new person dialog
    $('#dialog').dialog({
        modal: true,
        modal: true,
        //            show: "clip",
        //          hide: "explode",
        autoOpen: false,

        title: "انتخاب فاکتور",
        open: function (type, data) {
            $(this).parent().appendTo("form");
        }
    });

    //setup edit person dialog
    $('#editPerson').dialog({
        autoOpen: false,
        draggable: true,
        title: "Edit Person",
        open: function (type, data) {
            $(this).parent().appendTo("form");
        }
    });
});

function showDialog(id) {
    $('#' + id).dialog("open");
}

function closeDialog(id) {
    $('#' + id).dialog("close");
}

The Code Is in UserControl . i can show Dialog client Side :

and i can register code from server with this code :

Page.ClientScript.RegisterClientScriptBlock(GetType(String), "script", "$(function() {showDialog('dialog');});", True)

this code works in page but not in user control. how can i fix it?

HTML Code :

'> ' runat="server" />
A: 

Not sure whether this is the issue or not. Since UserCOntrol is a naming container your element id might have changed. So you need to get the id using ClientID.

Change your code to something like this

$("#<%=yourbuttonid.ClientID%>").dialog("open");
rahul
i have html Control... ClientID?
shaahin
Do you have `runat="server"` attribute set on that control?
rahul
A: 

shaahin, what exactly is "dialog"? Is this element in your HTML?

Please post the code where you define this element and we will all be wiser. :)

Shadow Wizard
This should really be added as a comment since it is not an answer? :)
IrishChieftain
Very true, but I couldn't post comments being new with less than 50 reputation and needed this information in order to help. Still waiting for the OP to give this information. :)
Shadow Wizard
A: 

Check the rendered HTML code of your page. Is the order of your script blocks correct? The setup block should be first there, and the showDialog call block should be rendered somewhere below it. Is it your case?

thorn