简体   繁体   English

如何在ASP.NEt应用程序中使用来自jQuery PopUpDialog的控件

[英]How I can use the Controls from jquery PopUpDialog in my ASP.NEt Application

My Application: 我的应用程序:

I have a ASP.NET Application with two parts. 我有一个包含两个部分的ASP.NET应用程序。 First part is the "Absence" Part and the second part is "Signature". 第一部分是“缺席”部分,第二部分是“签名”。 This Application create this parts Automatic. 此应用程序自动创建此零件。 For Absence the User must input the Enddate from this absence and a representative. 对于缺席,用户必须输入缺席的结束日期和代表。 The TextBox for the representative have a AutoComplete that get Data from the Active Directory. 代表的文本框具有一个自动完成功能,该功能可以从Active Directory中获取数据。 And with a Image on the right side of the textbox, the user can search a representative in a Modal popup from jQuery. 并且在文本框的右侧有一个Image,用户可以在jQuery的Modal弹出窗口中搜索代表。 The Popup has one textbox and a imagebutton with a magnifying glass Symbol. 弹出窗口有一个文本框和一个带放大镜符号的图像按钮。 Now I want that if I click on this Symbol I get all found representative in a ListView in the PopUpBox with a fixed Width and Height. 现在,我希望如果单击此符号,我将在PopUpBox的ListView中找到所有具有固定宽度和高度的代表。

My Problem: 我的问题:

My PopUp open and I can set my Controls in the div block for this popupdialog. 我的弹出窗口打开,我可以在此弹出对话框的div块中设置控件。 I have create a Event for my ImageButton and generate the Code for this but if I click on the Button (in the popupdialog) the Code don't work. 我已经为我的ImageButton创建了一个Event并为此生成了代码,但是如果我单击Button(在弹出对话框中),则该代码不起作用。 It doesn't jump in the Button_click Method :( 它不会在Button_click方法中跳转:(

My Question: 我的问题:

How I can use the Controls in my popupdialog with jquery and asp.net? 如何在jquery和asp.net的popupdialog中使用控件?

Here my Code: 这是我的代码:

ASPX: (jquery code) ASPX:(jQuery代码)

<script type="text/javascript" language="javascript">

        $(document).ready(function () {
            $("#dialogbox").dialog({
                autoOpen: false,
                modal: true,
                resizable: false,
                buttons: {
                    "OK": function () {
                        $(this).dialog("close");
                    },
                    "Cancel": function () {
                        $(this).dialog("close");
                    }
                }
            });

            $("#imgVertreter").click(function () {
                $("#dialogbox").dialog("open");
                return false;
            });
        }); 

    </script>

aspx: (my popupdialogbox div code) aspx :(我的popupdialogbox div代码)

<div id="dialogbox" title="Gesammte Vertreterliste">
        <asp:TextBox ID="pVertreter" runat="server"></asp:TextBox>
        <asp:ImageButton ID="pImageSearch" runat="server" 
        ImageUrl="~/App_Theme/lupe.jpg" Height="23px" Width="24px" 
            onclick="pImageSearch_Click" /><br />
        <hr />
        <asp:ListView runat="server" ID="ListView">

            <LayoutTemplate>
                <table id="UserTable" runat="server" border="0" width="100%" cellpadding="0" cellspacing="0">
                    <tr style="background-color:#ccdaeb" class="tableClass">
                        <th align="left" id="th4" runat="server"><asp:Label ID="lblName" runat="server" Text="Name, Vorname"></asp:Label></th>
                        <th align="left" id="th3" runat="server"><asp:Label ID="lblAbteilung" runat="server" Text="Abteilung"></asp:Label></th>
                    </tr>
                </table>
            </LayoutTemplate>

            <ItemTemplate>
                <tr>
                  <td align="left"><asp:LinkButton CssClass="MyLink" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="lblFullname" Text='<%# Eval("Name") %>' runat="server"></asp:LinkButton></td>
                  <td align="left"><asp:LinkButton CssClass="MyLink" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="lblAbteil" Text='<%# Eval("Abteilung") %>' runat="server"></asp:LinkButton></td>
                </tr>
            </ItemTemplate>

            <EmptyDataTemplate>
                Es wurden keine Einträge gefunden
            </EmptyDataTemplate>

            <AlternatingItemTemplate>
                <tr class="TableClass">
                    <td align="left"><asp:LinkButton CssClass="MyLink" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="lblFullname" Text='<%# Eval("Name") %>' runat="server"></asp:LinkButton></td>
                  <td align="left"><asp:LinkButton CssClass="MyLink" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="lblAbteil" Text='<%# Eval("Abteilung") %>' runat="server"></asp:LinkButton></td>
                </tr>
            </AlternatingItemTemplate>

        </asp:ListView>

    </div>

My C# Code for the imageButton (pImageSearch) 我的imageButton的C#代码(pImageSearch)

 protected void pImageSearch_Click(object sender, ImageClickEventArgs e)
        {
            try
            {
                UserService srv = new UserService();

                DataTable dt = srv.BenutzerFinden(Domain, pVertreter.Text);
                DataView dv = new DataView(dt);

                dv.Sort = "Nachname ASC";

                this.ListView.DataSource = dv;
                this.ListView.DataBind(); 
            }
            catch (Exception)
            {

            }


        }

Here is a Picture from my Application : 这是我的应用程序中的图片:

在此处输入图片说明

Sourcecode in IE for my TestApplication that works! IE中适用于我的TestApplication的源代码有效!

<div id="dialog" title="Liste">
<input name="txtBox" type="text" value="rettet" id="txtBox" />
<input type="submit" name="btnEdit" value="übergeben" id="btnEdit" />
</div>

Sourcecode for my main Application that don't work! 我的主要应用程序的源代码不起作用!

<div id="dialogbox" title="Vertreterliste">
<input name="pVertreter" type="text" id="pVertreter" />
<input type="image" name="pImageSearch" id="pImageSearch" src="App_Theme/lupe.jpg" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;pImageSearch&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, false))" style="height:23px;width:24px;" /><br />
<input type="submit" name="suchen" value="suchen" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;suchen&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, false))" id="suchen" />
</div>

Why is here a onclick with a dopostback Oo? 为什么这里是带有dopostback Oo的onclick?

jQuery modals are created by cloning the DOM elements and placing them at the of the body tag. jQuery模态是通过克隆DOM元素并将其放置在body标签的来创建的。 This create valid DOM elements and it works fine on the client side. 这样可以创建有效的DOM元素,并且可以在客户端正常运行。

However for asp.net controls to send events, they must be inside the form tag(asp.net creates only one form tag). 但是,为使asp.net控件发送事件,它们必须位于表单标签内(asp.net仅创建一个表单标签)。

The solution is to create the dialog and then place the elements back into the form tag. 解决方案是创建对话框,然后将元素放回到form标签中。

    $(document).ready(function () {
        $("#dialogbox").dialog({
            autoOpen: false,
            modal: true,
            resizable: false,
            buttons: {
                "OK": function () {
                    $(this).dialog("close");
                },
                "Cancel": function () {
                    $(this).dialog("close");
                }
            }
        });

        $("#dialogbox").parent().appendTo($("form:first"));

        $("#imgVertreter").click(function () {
            $("#dialogbox").dialog("open");
            $("#dialogbox").parent().appendTo($("form:first"));
            return false;
        });          
    }); 

Your server events should now fire perfectly after that. 在此之后,您的服务器事件现在应该完美触发。

Use JavaScript like this: 像这样使用JavaScript:

(function(){
    var popups = $('.js-popups');

    popups.magnificPopup({
        type:'inline',
        midClick: true,
        preloader: true,
        fixedContentPos: false,
        closeMarkup: '<span class="popup-close-ic mfp-close"></span>',
        removalDelay: 300,
        appendTo: 'form',
        prependTo: 'form'
    });
})();

Add the extra prependTo: 'form' for form submission. 添加额外的prependTo: 'form'以提交表单。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用Postmark进行ASP.NET登录控件? - How can I use Postmark for ASP.NET Login controls? 如何从解决方案中的类访问ASP.NET页面上的控件? - How can I access the controls on my ASP.NET page from a class within the solution? 我可以在asp.net应用程序中使用Lync api吗? - Can I use a Lync api in my asp.net application? 如何使用枚举中的值从ASP.NET MVC Web应用程序中的模型填充下拉列表? - How can I use values from an enum to populate a dropdownlist from my model in an ASP.NET MVC web application? 我可以使用SQL Server安全性来控制对(数据库优先)ASP.net应用程序的访问吗? 怎么样? - Can I use SQL Server security to control access to my (database first) ASP.net application? How? 如何在我的 ASP.NET Core 应用程序中使用 Startup.cs 之外的服务? - How can I use a service outside of Startup.cs in my ASP.NET Core Application? 如何在ASP.net Core应用程序中同时使用Bearer和Cookie身份验证? - How can I use both Bearer and Cookie authentication in my ASP.net Core application? 我如何在c#asp.net应用程序中使用jquery实现文本框自动建议? - How can i implement textbox auto suggest using jquery in my c# asp.net application? 如何使用ASP.NET应用程序中的XML文件中的数据填充我的DropDownList - How I can fill my DropDownList with Data from a XML File in my ASP.NET Application 我如何在ASP.NET应用程序中使用Session很长时间 - How I can use a Session for a long time in my ASP.NET Application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM