使用引导程序模式asp.net回发时,文本框为空 [英] textboxes are empty on postback with bootstrap modal asp.net

查看:63
本文介绍了使用引导程序模式asp.net回发时,文本框为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的asp.net页面中使用引导程序模版,如下所示:

I am using bootstrap modal in my asp.net page like this:

   <div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
            aria-hidden="true">
<asp:UpdatePanel ID="ModalUpdatePanel" runat="server" UpdateMode="Conditional">
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="btnRegister" EventName="Click" />
    </Triggers>
    <ContentTemplate>
        <p>

textboxes here


 <div class="popup-footer-wrapper">
                <div class="popup-footer-left">
                    <%-- <input type="submit" class="login-button" name="login-button" value="Sign Up">--%>
                    <asp:Button ID="btnRegister" runat="server" CssClass="login-button" OnClick="btnRegister_Click"
                        UseSubmitBehavior="false" Text="<%$ Resources: HRGELoggedOutMaster, Signup %>" />

                </div>
            </div>

        </p>
    </ContentTemplate>
</asp:UpdatePanel>
</div>

我在里面看到

  protected void btnRegister_Click(object sender, EventArgs e)

所有texboxs显示空值.在文本框中键入任何用户.请提出解决方法.可能是因为UseSubmitBehavior ="false",但如果我不使用它,则控件不会进入onclick事件.

all the texboxes show empty value. whatever user type in textbox. Please suggest how to fix it. It may be because of UseSubmitBehavior="false" but if i dont use it then control doesnt go to onclick event.

推荐答案

之所以看不到已发布的值,是因为未发布您的值.引导程序模式管理器将'body'元素用作附加模式的根元素.结果,您的模态现在不在"form"元素之外,并且值也没有被发布回服务器.

The reason why the you are not seeing your posted values, is because your values are not being posted. The bootstrap modal manager uses the 'body' element as the root element to which it appends your modals. As a result your modals are now outside the 'form' element and the values are not being posted back to the server.

要解决此问题,请更改"manager"属性的默认值,如下所示:

To fix this, change the default value of the 'manager' property as follows:

// Note the manager is passed to the root form element. 
// Otherwise, the modals are taken out of the form and 
// values not posted back to the server
$.fn.modal.defaults.manager = $.fn.modalmanager.defaults.manager = 'body form:first';

这是假设您正在使用 Bootstrap-Modal扩展

This is assuming you are using the Bootstrap-Modal Extension

这篇关于使用引导程序模式asp.net回发时,文本框为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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