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;
}
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
<asp:ModalPopupExtender ID="mp1" runat="server" PopupControlID="Panl1" DropShadow="true"
TargetControlID="cmd_add_key" CancelControlID="cmd_cancel"
onload="mp1_Load"></asp:ModalPopupExtender>