Search code examples
jqueryjquery-dialog

Microsoft JScript runtime error: Object doesn't support property or method 'dialog'


I am using an .ascx user control where i populating employee data along with employee picture. while on clicking employee picture i want to display a dialog where i want to have one text field and a text box for input from user. Click event is firing fine but with dialog it gives me the error of "Microsoft JScript runtime error: Object doesn't support property or method 'dialog'". Could please anyone help me to populate a dialog with a text field and text box. I am really new to the JQUERY and struggling to get it work.

In the following code snippet i have added a dialog code from one of the example i found online.

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="OpenAccessDataProvider,a4a794260c0b4440b466f75d11146db8.ascx.cs" Inherits="SitefinityWebApp.SfCtrlPresentation.OpenAccessDataProvider_a4a794260c0b4440b466f75d11146db8" %>
<%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI.PublicControls.BrowseAndEdit" Assembly="Telerik.Sitefinity" %>
<%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI.ContentUI" Assembly="Telerik.Sitefinity" %>
<%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI.Comments" Assembly="Telerik.Sitefinity" %>
<%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI.Fields" Assembly="Telerik.Sitefinity" %>
<%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI" Assembly="Telerik.Sitefinity" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>

<telerik:RadListView ID="dynamicContentListView" ItemPlaceholderID="ItemsContainer" runat="server" EnableEmbeddedSkins="false" EnableEmbeddedBaseStylesheet="false">
    <LayoutTemplate>
        <ul class="sfitemsList sfitemsListTitleDateTmb">
            <asp:PlaceHolder ID="ItemsContainer" runat="server" />
        </ul>
    </LayoutTemplate>

        <ItemTemplate>
      <li class="sfitem sfClearfix">
            <h2 class="sfitemTitle">
                <sf:DetailsViewHyperLink ID="DetailsViewHyperLink" TextDataField="Title" runat="server" />
            </h2>
           <sf:AssetsField ID="AssetsField1" runat="server" DataFieldName="Picture" />
           <sf:SitefinityLabel ID="SitefinityLabel1" runat="server" Text='<%# Eval("Designation")%>'  WrapperTagName="div" HideIfNoText="true" CssClass="sfitemShortTxt" />           
          <sf:SitefinityLabel ID="SitefinityLabel2" runat="server" Text='<%# Eval("CompanyName")%>' WrapperTagName="div" HideIfNoText="true" CssClass="sfitemShortTxt" />
          <sf:AssetsField ID="AssetsField2" runat="server" DataFieldName="Documents"/>
      </li>
    </ItemTemplate>
</telerik:RadListView>

<sf:Pager id="pager" runat="server"></sf:Pager>

<script type="text/javascript">
    $(document).ready(function () {
        $(".sfClearfix .sfimageWrp img").click(function () {

//            $(document).ready(function () {
                var $dialog = $('<div></div>')
        .html('This dialog will show every time!')
        .dialog({
            autoOpen: false,
            title: 'Basic Dialog'
        });

                $('#opener').click(function () {
                    $dialog.dialog('open');
                    // prevent the default action, e.g., following a link
                    return false;
                });
//            });

            //alert("HEY THERE " + $(this).attr("src")); 
        });
    });
</script>

Regards.

Solution

  • Got it working guys. Just added a div that is for dialog and than from picture click just called the div. Also, added a JQuery.noConflict(); to prevent any conflicts between Sitefinity and JQuery libraries. Following is the code snippet

    <div class="dialogTest"> <br />
    <br />
    Please enter your email address: <input type="text" name="emailAddress" style="width:300px;" /><br /><br />
    
    <asp:TextBox ID="txtBox" runat="server"></asp:TextBox> <br/>
    <asp:Button ID="Button1" runat="server" Text="Button" CausesValidation="False" 
            onclick="Button1_Click" />
    </div>
    
    <script type="text/javascript">
    $j = jQuery.noConflict();
    $j(document).ready(function () {
        $j(".sfClearfix .sfimageWrp img").click(function () {
            $j(".dialogTest").addClass("open");
            //return $j(this).attr("src");
        });
    });
    </script>