Archive for category Trouble Shooting

Solution to: The type System.IO.Packaging.Package’ is defined in an assembly that is not referenced. You must add a reference to assembly ‘WindowsBase

Description:

In article I am going to explain the solution of a problem which you may face when you work with Open Office XML SDK and DocumentFormat.OpenXML assembly in Asp.Net. After adding the needed reference when you build the project you will get exception “The type ‘System.IO.Packaging.Package’ is defined in an assembly that is not referenced. You must add a reference to assembly ‘WindowsBase’”

Solution:

To resolve this issue you need to add the reference of WindowsBase dll reference to your solution.

, , ,

Leave a comment

Trouble Shooting: Asp.Net AjaxControlToolkit ReOrderList control not working in IE 11 Browser

Introduction

In this article I am going to provide a solution for the problem where the Asp.Net AjaxControlToolkit’s ReOrderList control won’t work in IE 11 Browser.

Problem Description:

In IE11 browser AjaxControlToolkit ReOrderList’s changing the order of items (ReOrder) won’t work properly. You don’t get any error however when you try to drag there won’t be any changes to ReOrderList.

Solution:

To resolve this issue you need to set the ClientIDMode to control to AutoID and it will resolve the issue.

CSS:

  <style type="text/css">
            .DragHandleClass {
                width: 40px;
                height: 20px;
                background-color: blue;
                color: white;
                cursor: move;
            }

            .ajaxOrderedList li {
                list-style: none;
            }
        </style>

HTML

 <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></asp:ToolkitScriptManager>
        <asp:ReorderList ID="ReorderList1" runat="server"
            OnItemReorder="ReorderList1_ItemReorder"
            PostBackOnReorder="true"
            CallbackCssStyle="callbackStyle"
            DragHandleAlignment="Left"
            ItemInsertLocation="Beginning"
            DataKeyField="ID"
            SortOrderField="Name" ClientIDMode="AutoID">
            <ItemTemplate>
                <div class="itemArea">
                    <asp:Label ID="Label1" runat="server" Text='<%#Eval("Name")%>' />
                    <asp:Label ID="Label2" runat="server" Text='<%#Eval("Order_By") %>' />
                </div>
            </ItemTemplate>
            <ReorderTemplate>
                <asp:Panel ID="Panel2" runat="server" CssClass="reorderCue" />
            </ReorderTemplate>
            <DragHandleTemplate>
                <div class="DragHandleClass">Drag</div>
            </DragHandleTemplate>
        </asp:ReorderList>

C#:



public static DataTable dt = null;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

                //test data suppose comes from database
                dt = new DataTable();
                dt.Columns.Add("ID");
                dt.Columns.Add("Name");
                dt.Columns.Add("Order_By");
                dt.Rows.Add(1, "Name1", "First");
                dt.Rows.Add(2, "Name2", "Second");
                dt.Rows.Add(3, "Name3", "Third");
                dt.Rows.Add(4, "Name4", "Fourth");
                this.ReorderList1.DataSource = dt;
                this.ReorderList1.DataBind();
            }

        }

        protected void ReorderList1_ItemReorder(object sender, AjaxControlToolkit.ReorderListItemReorderEventArgs e)
        {
            DataRow selectedRow = dt.Rows[e.OldIndex];
            DataRow newRow = dt.NewRow();
            newRow.ItemArray = selectedRow.ItemArray; // copy data
            dt.Rows.Remove(selectedRow);//delete the old row
            dt.Rows.InsertAt(newRow, e.NewIndex); //add new row
            //your code save the datatable to database
            this.ReorderList1.DataSource = dt;
            this.ReorderList1.DataBind();
        }

Demo:

, ,

Leave a comment

Trouble Shooting: Unable to perform postback from Jquery Dialog

Problem Description:

From Jquery Dialog when you click on the button and if it has a corresponding click event on server side code, the code won’t get executed.

Solution:

You need to add the below code to perform postback when user click on button in Jquery dialog.

parent().appendTo(jQuery(&quot;form:first&quot;));

Complete Code

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <link rel="stylesheet" href="//code.jquery.com/ui/1.11.3/themes/smoothness/jquery-ui.css">
    <script src="//code.jquery.com/jquery-1.10.2.js"></script>
    <script src="//code.jquery.com/ui/1.11.3/jquery-ui.js"></script>
    <link rel="stylesheet" href="/resources/demos/style.css">
    <script>
        $(function () {
            $("#dialog").dialog({
                autoOpen: false
            });

            $("#Button1").click(function (evt) {
                var dlgwnd = $("#dialog").dialog("open");
                //Add the below code and Postback will occur fine with out any problem
                dlgwnd.parent().appendTo(jQuery("form:first"));
            });
        });
    </script>
</head>
<body>
    <form id="form2" runat="server">
        <div id="dialog" title="Dialog">
            Sample Text Content
            <asp:Button ID="Button2" runat="server" Text="OK" OnClick="Button2_Click" />
        </div>

        <asp:Button ID="Button1" runat="server" Text="Open Dialog" OnClientClick="return false" />
    </form>
</body>
</html>

Leave a comment