如何将值传递给模态形式 [英] how to pass a value to modal form
问题描述
大家好,
我的主aspx表格中有以下代码。
Hi all,
I have the following code in my main aspx form.
<asp:button id="Button1" name="cmd_add_key" runat="server" OnClick="add_keys" Text="Attach keys" />
<asp:ToolkitScriptManager ID="ToolkitScriptManager2" runat="server"></asp:ToolkitScriptManager>
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" PopupControlID="Panl1" DropShadow="true"
TargetControlID="cmd_add_key" CancelControlID="cmd_cancel" ></asp:ModalPopupExtender>
<asp:Panel ID="Panel1" runat="server" CssClass="#transparent" align="center" style = "display:none; background-color:White;">
<iframe style=" width: 800px; height: 300px;" id="Iframe1" src="getKeysforAddUpdatePropertyKey.aspx?PropertyId=324" runat="server"></iframe>
<br/>
<asp:Button ID="Button2" runat="server" Text="Close" class="btn btn-primary"/>
</asp:Panel>
以下是add_keys方法背后的代码
Following is the code behind of add_keys method
protected void add_keys(object sender, EventArgs e)
{
string url = "getKeysforAddUpdatePropertyKey.aspx?PropertyId=" + txt_property_id.Text;
irm1.Attributes["src"] = url;
}
现在每次调用表单时,我都会得到值324,我理解这是页面中的默认值。然而,我正在寻找一种可以改变价值的方法。我认为通过在add_keys方法中编写代码可以解决问题,但是它完全被忽略了,我总是得到324.
任何帮助都将不胜感激。
非常感谢提前
Now every time I call the form, I get the value 324 which I understand is the default value in page. I am however looking for a way where I can change the value. I thought by writing the code in add_keys method will do the trick, however it is completely ignored and I always get 324.
Any help would be appreciated.
Many thanks in advance
推荐答案
管理自己解决问题。希望它会帮助别人
我将代码从add_keys方法移动到ModalPopupExtender的加载方法(mp1)
Managed to solve the problem myself. Hope it will help someone else
I moved the code from add_keys method to load method of ModalPopupExtender (mp1)
protected void mp1_Load(object sender, EventArgs e)
{
string url = "getKeysforAddUpdatePropertyKey.aspx?PropertyId=" + txt_property_id.Text;
irm1.Attributes["src"] = url;
}
在前端(aspx页面)改变了
On the front end (aspx page) changed
<asp:ModalPopupExtender ID="mp1" runat="server" PopupControlID="Panl1" DropShadow="true"
TargetControlID="cmd_add_key" CancelControlID="cmd_cancel"
</asp:ModalPopupExtender>
to
to
<asp:ModalPopupExtender ID="mp1" runat="server" PopupControlID="Panl1" DropShadow="true"
TargetControlID="cmd_add_key" CancelControlID="cmd_cancel"
onload="mp1_Load"></asp:ModalPopupExtender>
这篇关于如何将值传递给模态形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!