Ron*_*fca 2 html c# asp.net-ajax
我有一个ModalPopupExtender,允许客户应用付款信息.它一直很好用.然后客户要求在ModalPopup上查看到期总额.仅从父控件获取总数并将其传递到ModalPopup控件似乎不是什么大不了的事.似乎没有简单的方法可以做到这一点.
这是我的HTML代码,请记住,此代码包含在UpdatePanel中
<asp:LinkButton ID="lnkMakePayment" runat="server" Visible="true" OnClick="lnkMakePayment_Click" >
<asp:Label ID="lblMakePayment" runat="server" Text="Make Payment"/></asp:LinkButton>
<asp:Button ID="btnDummy" style="display: none;" runat="server"
OnClick="btnDummy_Click" />
<ajaxToolkit:ModalPopupExtender ID="mdlPopupPayment" runat="server"
TargetControlID="btnDummy" PopupControlID="pnlMakePayment"
CancelControlID="popUpCancel" DropShadow="true" BackgroundCssClass="modalBackground">
</ajaxToolkit:ModalPopupExtender>
<asp:Panel ID="pnlMakePayment" runat="server" Style="display: none;"
SkinID="PopUpPanel" class="ContentBoxColor" Width="400px" Height="170px">
<MP1:MakePaymentPopup ID="MakePayment" runat="server" />
<div style="text-align: right; width: 100%; margin-top: 5px;">
<asp:Button ID="popUpCancel" runat="server" Text="Cancel" Width="0px" />
</div>
</asp:Panel>
Run Code Online (Sandbox Code Playgroud)
现在这里是代码隐藏
protected void btnDummy_Click(object sender, EventArgs e) { }
protected void lnkMakePayment_Click(object sender, EventArgs e)
{
mdlPopupPayment.Show();
}
Run Code Online (Sandbox Code Playgroud)
因此,当用户点击付款链接时,ModalPopup工作正常.它甚至会触发父控件侦听的事件,以应用付款信息以及用户在弹出窗口中填写的所有相关付款详细信息.这一切都很好.
由于ModalPopup,我首次尝试发送总数如下:
protected void lnkMakePayment_Click(object sender, EventArgs e)
{
// MakePayment is the actual ModalPopup control and total due is a public property
MakePayment.TotalDue = txtTotalDue.Text
mdlPopupPayment.Show();
}
Run Code Online (Sandbox Code Playgroud)
这个问题是,当我单击链接以显示ModalPopup时,PageLoad事件不会触发,因此我无法将我的属性分配给ModalPopup内的标签.我甚至尝试使用会话对象,但遇到了同样的问题.我甚至无法访问数据库,因为我无法传递客户ID.有任何想法吗?我是Javascript的新手,并且在服务器方面有灵魂,但此时我愿意尝试任何事情.
MakePayment用户控件包含3个asp文本框.一个用于用户输入支付金额,另一个用于支付类型,第三个用于支票,例如支票号码.在控件上还有一个应用和取消按钮.父控件是一个基本的ascx页面,它是一个数据输入屏幕,包含ModalPopupExtender和所有激活它的html代码.
小智 6
没有必要创建用户控件以将数据传递到模式弹出窗口.如果我需要在不同的位置重用它,我只会创建一个用户控件.如果您不需要在多个位置重复使用它,那么您不需要用户控件.而是这样做:
假设您需要一个显示字符串并具有"确定"和"取消"按钮的弹出窗口,但您需要在弹出之前设置字符串值.
在弹出扩展器下面的UpdatePanel中放置一个标签,Ok和Cancel按钮.如下所示:
<asp:Panel ID="Panel1" runat="server" CssClass="popup" Width="320px" Style="display:none">
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Button ID="Button1" runat="server" Style="display:none" />
<cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server"
TargetControlID="Button1"
PopupControlID="Panel1"
CancelControlID="CancelButton">
</cc1:ModalPopupExtender>
<asp:Label ID="Label1" runat="server" />
<asp:Button ID="OkButton" runat="server" Text="Ok" CausesValidation="true" OnClick="OkButton_OnClick" />
<asp:Button ID="CancelButton" runat="server" Text="Cancel" CausesValidation="false" />
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
Run Code Online (Sandbox Code Playgroud)接下来,在您的页面上,放置一个Button和一个TextBox,如下所示:
<asp:TextBox ID="MyTextBox" runat="server" />
<asp:Button ID="MyButton" runat="server" Text="Popup" OnClick="MyButton_OnClick" />
Run Code Online (Sandbox Code Playgroud)现在,在页面背后的代码中,放置处理程序MyButton:
protected void MyButton_OnClick(object sender, EventArgs e)
{
Label1.Text = MyTextBox.Text;
UpdatePanel1.Update();
ModalPopupExtender1.Show();
}
Run Code Online (Sandbox Code Playgroud)| 归档时间: |
|
| 查看次数: |
19399 次 |
| 最近记录: |