Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I have the following code in my main aspx form.


XML
<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>


Following is the code behind of add_keys method

C#
protected void add_keys(object sender, EventArgs e)
{
    string url = "getKeysforAddUpdatePropertyKey.aspx?PropertyId=" + txt_property_id.Text;
    irm1.Attributes["src"] = url;
}


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
Posted
Comments
Sergey Alexandrovich Kryukov 5-Nov-13 18:21pm    
What do you mean by "call the form"? It is not a method, function, procedure, subroutine, property or operator... :-)
Basically: modality is irrelevant here. What is that 324? a value of what? why default?..
—SA
Member 8430279 6-Nov-13 2:15am    
Sorry by "call the form" I mean when the popup open the form "getKeysforAddUpdatePropertyKey.aspx". 324 is just a default value. I actually want to pass a number in textBox "txt_property_id".
Madhu Nair 5-Nov-13 23:24pm    
Do you want Random Values for PropertyId Query string?
Member 8430279 6-Nov-13 2:12am    
Rather than 324 which is just a static value, I want to pass a value which is in my textBox. I have tried debugging and the method "add_keys" is not even called.

1 solution

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)

C#
protected void mp1_Load(object sender, EventArgs e)
{
    string url = "getKeysforAddUpdatePropertyKey.aspx?PropertyId=" + txt_property_id.Text;
    irm1.Attributes["src"] = url;
}


On the front end (aspx page) changed

XML
<asp:ModalPopupExtender ID="mp1" runat="server" PopupControlID="Panl1" DropShadow="true"
    TargetControlID="cmd_add_key" CancelControlID="cmd_cancel"
    </asp:ModalPopupExtender>


to

XML
<asp:ModalPopupExtender ID="mp1" runat="server" PopupControlID="Panl1" DropShadow="true"
    TargetControlID="cmd_add_key" CancelControlID="cmd_cancel"
    onload="mp1_Load"></asp:ModalPopupExtender>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900