JQuery的BlockUI与UpdatePanel的视图状态问题 [英] JQuery BlockUI with UpdatePanel Viewstate Issue

查看:266
本文介绍了JQuery的BlockUI与UpdatePanel的视图状态问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用BlockUI显示一个模式。在阻塞模式我有一个更新面板。在更新面板我有一个文本框和提交的内容返回到服务器的按钮。一切工作正常到这点(blockUI被调用时,出现的模式,和按钮进行回传)。然而,当该按钮的Click事件被触发值的文本框为空一贯即使是输入的文本。当更新面板更新文本框显示空白。看来,这可能是某种ViewState的问题,我还没有关闭的视图状态。

I am using BlockUI to show a modal. Within the blocked modal I have an update panel. Within the update panel I have a textbox and a button that submits the content back to the server. Everything works fine up to this point (the blockUI is called, the modal appears, and the button performs the postback). However, when the button's click event is fired the value for the textbox is consistently empty even if text was entered. When the update panel updates the textbox shows up blank. It appears that this may be some sort of viewstate issue and I haven't turned off viewstate.

<a href="javascript:$.blockUI({ message: $('#divTest') });">SHOW MODAL</a>

<div id="divTest" style="display: none;">
<asp:UpdatePanel ID="upTest" UpdateMode="Conditional" runat="server">
    <ContentTemplate>
        <asp:TextBox ID="txtTestVS" runat="server" /><br />
        <asp:Button ID="cmdTest" Text="TEST" OnClick="cmdTest_Click" UseSubmitBehavior="false" runat="server" />
    </ContentTemplate>
</asp:UpdatePanel>

服务器端:

protected void cmdTest_Click(object sender, EventArgs e)

{
  字符串x = txtTestVS.Text;
 }

{ string x = txtTestVS.Text; }

字符串X总是等于。

推荐答案

这是对话的插件一个共同的问题,问题是当内容被放在blockUI容器,它是附加在 &LT;身体GT; 元素,形式不再被提交到服务器。为了解决这个问题,你需要编辑blockUI code了一下:

This is a common problem with dialog plug-ins, the problem is when content is put in the blockUI container, it's appended to the <body> element, and no longer in the form being submitted to the server. To solve this you need to edit the blockUI code a bit:

下面是源:<一href=\"http://github.com/malsup/blockui/blob/master/jquery.blockUI.js\">http://github.com/malsup/blockui/blob/master/jquery.blockUI.js

更改此:结果
262线: VAR层= [lyr1,lyr2,lyr3],$ PAR =满了吗? $(身体):$(EL); 结果
于: VAR层= [lyr1,lyr2,lyr3],$ PAR =满了吗? $(形式):$(EL);

和这样的:结果
382线:埃尔斯= $('身体')儿童()过滤器('blockUI。')加('身体GT; .blockUI');
于:。埃尔斯= $('形式')儿童()过滤器('。blockUI')加('形式&GT; .blockUI');

这应该让你去和文本框的值未来通过。

That should get you going and the textbox values coming through.

这篇关于JQuery的BlockUI与UpdatePanel的视图状态问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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