Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6003797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:10:20+00:00 2026-05-23T01:10:20+00:00

There are several posts on StackOverflow on the subject but none of the answers

  • 0

There are several posts on StackOverflow on the subject but none of the answers helped me.
I am using the DataList control that is populated by a SELECT through a DataAdapter.
A concept is recommended that only one instance of the dialog must be open but could not apply this method

The structure of the html is:

<asp:DataList ID="DataList" runat="server">
         <ItemStyle />
         <ItemTemplate>
             <a href="" class="link"/></a>
             <div class = "dialog" id="dynamicID" style="display:none">
             </ div>
         </ ItemTemplate>
     </ asp: DataList>

The jQuery code I’m using is:

<script language="javascript" type="text/javascript">
     $ (function () {
         $ (". link. ") click (function () {
             var id = '#' + ($ (this). siblings ('. dialog'). attr ('id'));
             $ (id). dialog ({
                 AutoOpen: false,
                 closeOnEscape: true,
                 resizable: false,
                 draggable: false,
                 modal: true,
                 width: 800,
                 height: 600,
                 overlay: {backgroundColor: "# 000", opacity: 0.5},
                 top: 20,
                 show: 'fade',
                 hide: 'fade',
                 buttons: {
                     "Close": function () {
                         $ (id). dialog ('close');
                     }
                 }
             });
             $ (id). dialog ('open');
         });
     });
</ script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T01:10:20+00:00Added an answer on May 23, 2026 at 1:10 am

    Imagine this HTML

    <asp:DataList ID="dataList" runat="server">
        <ItemTemplate>
            <div class="row">
                <p>
                    Result: <strong>
                        <%# Container.DataItem.ToString() %></strong></p>
                <a href="#" class="link" data-open="dialog_<%# Container.ItemIndex %>" />Click
                To Open</a>
                <div class="dialog" id="dialog_<%# Container.ItemIndex %>">
                    <h2>
                        This is the text inside the dialog #
                        <%# Container.ItemIndex %>.</h2>
                    <p>
                        &nbsp;
                    </p>
                </div>
            </div>
        </ItemTemplate>
    </asp:DataList>
    

    with this javascript

    $(function () {
    
        // create dialogs
        $(".dialog").dialog({
            autoOpen: false,
            closeOnEscape: true,
            buttons: {
                "Close": function () {
                    $(id).dialog('close');
                }
            }
        });
    
        // hook up the click event
        $(".link").bind("click", function () {
            // console.log($(this).parent());
            // open the dialog
            var dialogId = $(this).attr("data-open");
            $("#" + dialogId).dialog("open");
    
            return false;
        });
    
    });
    

    works lovely.

    Working example can be found here

    What is wrong with your approach?

    you are creating the dialog’s inside a method, and this should be created inside the $(document).ready() so, everytime you click, it creates a dialog, but… it already exists and screws up everything.

    When working with dialogs:

    • First you create them using .dialog()
    • You just need to use .dialog('open') to make that dialog visible
    • And use .dialog('close') to hide that dialog

    by default jQuery UI CSS will hive the dialogs automatically (display:none;) so you don’t need to do anything like that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There are several other questions about this topic that I have gone through, but
There are several rank posts out there but I have yet to see one
I've seen several StackOverflow posts that discuss what tools to use to monitor web
I know there are several other posts on this topic but they still leave
I've searched the forum, and there are several posts about a questionnaire design, but
I see there are several posts regarding Cannot set Property and I'm still struggling
So, there have been several posts here about importing and saving data from an
I know there are several threads and posts regarding this issue in the internet
There are several threads on this here at SO but I didn't find one
There are several variant questions on this on SO, but I did not find

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.