Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
   I am using Jquery dialog. So i  click on Edit button it shows me dialog but when i click on Update button then its click event does not occur .

but if i use  <pre>$("#dialog_form").parent().appendTo($("#form:first"));
then both the dialog as well as page diabled.




JavaScript
$(document).ready(function () {

            var myDialog = $("#dialog_form").dialog({
                autoOpen: false,
                height: 500,
                width: 450,
                 modal: true,
//                open: function (event, ui) {
//                    $(this).parent().appendTo("#divDlgContainer");
//                },
                close: function () {

                }
            });



        });

        function showDialog() {

            $(function () {
                var myDialog = $("#dialog_form").dialog("open");
               // $("#dialog_form").parent().appendTo($("#form:first"));

            });
            return false;

        }
       
        function showUpdateMessage() {
            $(function () { $("#dialog_form").dialog("close"); });
            $('#Message').html("Record is Updated");
        }




C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using Model;
using System.Text;
using System.IO;

namespace Inventory_Management_System.Vendor
{
    public partial class Brands : System.Web.UI.Page
    {
        BuisnessLayer _objBuisnessLayer = new BuisnessLayer();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Databind();
            }

        }
        public void Databind()
        {
           
            dataListBrand.DataSource = _objBuisnessLayer.GetAllBrands();
            dataListBrand.DataBind();
        
        }
        protected void EditBrands(object sender, DataListCommandEventArgs e)
        {
           
             StringBuilder str=new StringBuilder();
            str.Append("showDialog()");
           Brand brand= _objBuisnessLayer.GetBrandById(Convert.ToInt32(e.CommandArgument.ToString()));
           OldImageBrand.ImageUrl = brand.Logo;
           txtBrandName.Text = brand.BrandName;
           txtHeadQuarter.Text = brand.Headquaters;
           txtBrandId.Text = brand.BrandCode.ToString();
            ScriptManager.RegisterClientScriptBlock(this,this.GetType(),"Key",str.ToString(),true);

        }
        protected void btnUpdate_Click(object sender, EventArgs e)
        {

            Brand brand = new Brand();
            brand.BrandCode = Convert.ToInt32(txtBrandId.Text);
            brand.BrandName = txtBrandName.Text;
            brand.Headquaters = txtHeadQuarter.Text;
            String path=Server.MapPath("~/Images/Brands/" + brand.BrandName + "/Logo.gif");
            if (fileUploadImage.HasFile)
            {
               
                fileUploadImage.SaveAs(path);
            }
            brand.Logo = path;
            if (_objBuisnessLayer.UpdateBrand(brand) > 0)
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Key", "showUpdateMessage()", true);
            else
                lblErrorMessage.Text = "error in updating records";



        
        }
    }
}




ASP.NET
<asp:Content ID="ContentBody" ContentPlaceHolderID="ContentPlaceHolderBody" runat="server">
    <div id="datalist">
        <asp:DataList ID="dataListBrand" runat="server" RepeatColumns="5" RepeatDirection="Horizontal"
            OnEditCommand="EditBrands">
            <ItemTemplate>
                <div class="items">
                    <div class="image">
                        <asp:Image ID="ImageLogo" ImageUrl='<%#Eval("Logo") %> ' AlternateText="Image" Width="160px"
                            Height="100px" runat="server" />
                    </div>
                    <asp:Label ID="lblBrandName" runat="server" Text='<%# Eval("BrandName") %>'></asp:Label></h1>
                    <asp:LinkButton runat="server" Text="Edit" CommandName="Edit" CommandArgument='<%# Eval("BrandCode") %>' />
                </div>
            </ItemTemplate>
            <EditItemTemplate>
            </EditItemTemplate>
            <AlternatingItemStyle BackColor="#F0F0F0" />
        </asp:DataList>
        <div id="Message">
        </div>
    </div>
    <div id="divDlgContainer">
    <div id="dialog_form" title="Update Or Cancel">
        <asp:Panel ID="PanelUpdate" runat="server">
            <asp:Image runat="server" ID="OldImageBrand" Height="100px" Width="350px" />
            <fieldset>
                <legend>Update</legend>
                <table>
                    <tr>
                        <td>
                            <asp:Label ID="lblBrandId" Text="Brand Id" runat="server" />
                        </td>
                        <td>
                            <asp:TextBox ID="txtBrandId" runat="server" ReadOnly="true" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:Label ID="lblNewBrandName" Text="Brand Name" runat="server" />
                        </td>
                        <td>
                            <asp:TextBox ID="txtBrandName" runat="server" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:Label ID="lblBrandHeadquater" Text="Headquater" runat="server" />
                        </td>
                        <td>
                            <asp:TextBox ID="txtHeadQuarter" runat="server" />
                        </td>
                    </tr>
                   <tr>
                        <td>
                            <asp:Button ID="btnUpdate" runat="server" OnClick="btnUpdate_Click" Text="Update" />
                        </td>
                    </tr>
                </table>
                <asp:Label ID="lblErrorMessage" runat="server" />
            </fieldset>
        </asp:Panel>
    </div>
    </div>
</asp:Content>
Posted
Updated 21-Aug-13 21:18pm
v3
Comments
ZurdoDev 21-Aug-13 10:32am    
Did you forget your question? How are we supposed to do anything with this?
Sergey Alexandrovich Kryukov 21-Aug-13 10:40am    
Not a question, not informative. Just a code dump.
For JavaScript, "ASP.NET controls" don't even exist. There are only resulting HTML controls. This is a client side...
—SA

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900