5

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.
3
  • it seems like jquery ui.js is not being loaded also keep in mind you have to include jquery.js before including any other library Commented Apr 23, 2012 at 9:13
  • Thanks for the advise 3nigma. I know jquery.js is not included in my code but as i mentioned i am working with a user control (.ascx file) where i dont know if i am allowed to add jquery.js script as we add any script in the header of .aspx pages while in user controls i dont have any header. any advise for that? i tried adding script directly and I am still ending up with same error "Microsoft JScript runtime error: Object doesn't support property or method 'dialog'" Commented Apr 23, 2012 at 10:11
  • It's some sort of an annoying conflict with the Telerik libraries. Commented Apr 14, 2014 at 22:31

3 Answers 3

7

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>
Sign up to request clarification or add additional context in comments.

2 Comments

Congrats on the fix! When you are able, please make sure to mark your answer as 'accepted' so that others will be able to learn from your success. Cheers~
Had some conflict between telerik and jquery and so the jquery ui dialog would throw an error. $j = jQuery.noConflict(); worked for me.
2

In my case, jquery files are not loaded properly. So what I did are: 1) Opened the page at Chrome 2) Selected the Developer tools from the menu or Ctrl+Shift+I 3) Clicked on Network to see all.

Comments

1

I had the same issue. problem was I had loaded 2 Jquery files. jquery-1.8.3.js and jquery-1.4.1.js . so there was a conflict. after removing jquery-1.4.1.js file . it worked smoothly.

Comments

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.