ASP.NET表单域从颜色框不张贴 [英] ASP.NET Form Fields Not POSTing from colorbox

查看:155
本文介绍了ASP.NET表单域从颜色框不张贴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这是一个jQuery的颜色框里面显示的形式。当提交表单时,该表单中的字段不被回发到页面。我修改了javascript来存储表单字段为隐藏字段上提交和那些确实张贴了回来。问题是,因为这是一个登录框,我真的不希望移动密码围绕这样。其主要形式是内容的更新面板内。这里是code为我的母版页:

I've got a form that is displayed inside a jQuery colorbox. When the form is submitted, the fields within that form are not being posted back to the page. I modified the javascript to store the form fields into hidden fields on a submit and those DO post back. The problem is, since this is a login box, I really don't want to move the password around like that. The main form content is inside an update panel. Here is the code for my master page:

<form id="myform" runat="server" clientidmode="Static" method="post">
    <asp:ScriptManager ID="ecommerceManager" runat="server" ClientIDMode="Static" EnableViewState="False" EnablePageMethods="True">
        <Scripts>
            <asp:ScriptReference Path="~/js/jquery-1.6.1.min.js" />
            <asp:ScriptReference Path="~/js/jquery.colorbox.min.js" />
            <asp:ScriptReference Path="~/js/eCommerce.js" />
        </Scripts>
    </asp:ScriptManager>

    <div style="width: 940px; margin-left: auto; margin-right: auto;">
        <div align="left">
            TOP OF THE PAGE
            <asp:ContentPlaceHolder ID="bodyContent" runat="server" ClientIDMode="Static">
            </asp:ContentPlaceHolder>
            BOTTOM OF THE PAGE
        </div>
    </div>

    <script type="text/javascript">
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(closeLoading);
        Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(loadData);
    </script>
    </form>

下面是一些来自我的主要默认页面的code使用母版页:

Here is some of the code from my main default page that uses the master page:

<asp:Content ID="mainContent" ContentPlaceHolderID="bodyContent" runat="server">


    <asp:UpdatePanel ID="ecommerceUpdate" runat="server" ClientIDMode="Static">
        <ContentTemplate>

            <asp:Panel ID="pnlEcomMain" runat="server" CssClass="ecom_main" ClientIDMode="Static">
                <asp:HiddenField ID="statusField" runat="server" ClientIDMode="Static" ViewStateMode="Disabled" EnableViewState="False" />
                <asp:HiddenField ID="hdnUsername" runat="server" ClientIDMode="Static" ViewStateMode="Disabled" EnableViewState="False" />


                <div class="add_product">
                    <div class="add_product_menu text_12_bold">
                        <asp:Image ID="imgAddProducts" ImageUrl="~/images/ecom_icon_add_2.gif" CssClass="std_btn" AlternateText="Add Products" runat="server" ClientIDMode="Static" />Add Additional Products:<br /><br />
                        <asp:DropDownList ID="newproduct" runat="server" ClientIDMode="Static" 
                            onchange="addProduct()">
                        </asp:DropDownList>
                    </div>
                </div>
                </asp:Panel>

                <div class="clear"></div>

                <!--- HERE IS THE COLORBOX POPUP CONTENT --->
            <div style="display: none; visibility: hidden;">
                <div id="inline_login">
                    <p><strong>User Login Details Go Here</strong></p>

                    User Name: <asp:TextBox ID="loginName" runat="server" ClientIDMode="Static" EnableViewState="False" ViewStateMode="Disabled" /><br />
                    Password: <asp:TextBox ID="loginPassword" runat="server" TextMode="Password" ClientIDMode="Static" /><br />
                    <input type="button" name="loginBtn" id="loginbtn" value="Login" onclick="javascript:validateLogin()" />



                </div>
            </div>

            </asp:Panel>

            <asp:Label ID="xmlContent" runat="server" />
       </ContentTemplate>
    </asp:UpdatePanel>

</asp:Content>

新的产品领域适当的职位,但用户名和密码不对,除非我一个职位之前将其复制到隐藏字段。我猜测也许是与更新面板有冲突?我本来试图获得登录控制更新面板中的工作,但在论坛上读到,有一个已知的问题与此有关。

The new product field properly posts, but the username and password doesn't UNLESS I copy it to the hidden fields before a post. I'm guessing maybe it's a conflict with the update panel? I was originally trying to get a Login Control working in the Update Panel but read in the forums that there is a known problem with this.

在这个任何有识之士将大大很是AP preciated。我使用Firebug可以确认域根本不在这就是为什么ASP没有找到他们的职位。

Any insight on this would very tremendously be appreciated. I'm using firebug and can confirm that the fields simply aren't in the post which is why ASP isn't finding them.

推荐答案

显然,尽管是在表单中的实际颜色框移动形式之外的内容。我能够加入这一行code到我的JavaScript提交函数来解决此问题:

Apparently, despite being inside the form, the colorbox actually moves the content outside the form. I was able to resolve this by adding this line of code to my JavaScript submit function:

jQuery('#inline_login').appendTo('form'); 

希望它可以帮助别人!

Hope it helps someone else!

这篇关于ASP.NET表单域从颜色框不张贴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆