1

I am working with JQueryUI and Asp.net and encounter a dynamic content problem:

<div id="content" title="" style="color: #F7A356"> 
<%=ContentLabel.Text%>
</div>

    function OpenDialog() {

   // alert(document.getElementById("content").innerHTML);

        var $dialog = $('<div style="color: #F7A356"></div>')
            .html($("#content").text())
            .dialog({
                autoOpen: false,
                modal: true,
                height: 150,
            });


            $dialog.dialog('open');

    }

I would like to open a dialog when I click on a control and show the content.. but it failed with the above method....

it doesn't work even I just some a simple javascript alert function with the innerHTML.....It return nothing as well

2 Answers 2

1

this is how it should look like..

$(document).ready(function() {
      .dialog({
         autoOpen: false,
         modal: true,
         height: 150,
     });

       $('a .opendialog').click(function(){
           $('#content').dialog('open');
       }
    });

if this does not help please provide more html

Sign up to request clarification or add additional context in comments.

1 Comment

watch that it should be $('#content') and not $('.content')
0

You should add the newly created element to the document before opening the dialog. Try something like:

$('<div style="color: #F7A356"></div>')
    .html($("#content").html())
    .appendTo("body")
    .dialog({
        modal: true,
        height: 150
    });

1 Comment

I had tried this method. but it doesn't work... the function .html() return "" (nothing). But if I initially put some text inside the <div></div>, the function .html() can get them out. but if I use <%= [an asp.net control .Text] %> it return nothing

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.