
372 N.W.2d 857 (1985)
Dallas A. HEIDT and Elaine E. Heidt, Plaintiffs and Appellants,
v.
STATE of North Dakota, Defendant and Appellee.
Civ. No. 10877.
Supreme Court of North Dakota.
August 15, 1985.
Thomas A. Dickson (argued), of Lundberg, Conmy, Nodland, Lucas & Schulz, Bismarck, for plaintiffs and appellants.
Robert P. Bennett, Asst. Atty. Gen., Bismarck, for defendant and appellee.
GIERKE, Justice.
This is an appeal by Dallas A. Heidt and Elaine E. Heidt [the Heidts] from an order denying their motion to enjoin foreclosure by advertisement. We reverse the order and remand for the entry of an order granting the injunction.
The Heidts conducted a farm ranch operation. On September 3, 1975, the Heidts borrowed $150,000 from the State of North Dakota. They secured this loan with the execution of a real estate mortgage on approximately 2,195.72 acres of their land in northeastern Burleigh County. They defaulted on the note. Thus, on July 18, 1984, the State [through the Bank of North Dakota] served the Heidts with a notice of intention to foreclose which stated that a principal and interest payment totaling *858 $40,710.48 was due in thirty days. The notice provided that if the default was not cured within 30 days, the whole amount of principal, along with interest through July 24, 1984, would be due, pursuant to Chapter 35-22 of the North Dakota Century Code. According to the record, the State complied with the procedural mandates of Chapter 35-22, N.D.C.C., entitled Foreclosure of Mortgages of Real Property By Advertisement.
On October 18, 1984, the Heidts presented to the District Court of Burleigh County a motion to enjoin the foreclosure and accompanied this motion with a supporting affidavit. The affidavit alleged what is referred to as the "confiscatory price defense", based on §§ 28-29-04, 28-29-05, and 28-29-06 of the North Dakota Century Code.[1]
The State's opposition to the Heidts' motion was filed on October 29, 1984, and a hearing was conducted the following day. The district court issued its order on November 1, 1984, denying the Heidts' motion to enjoin the foreclosure. This appeal followed.
The granting or denying of injunctive relief is vested in the sound discretion of the trial court. Eakman v. Robb, 237 N.W.2d 423 (N.D.1975). The district court's denial of the Heidts' motion will not be overturned on appeal unless there has been an abuse of discretion. Allen v. Minot Amusement Corp., 312 N.W.2d 698, 701 (N.D.1981). A trial court abuses its discretion when it acts in an arbitrary, unreasonable, or unconscionable manner. Schwarting v. Schwarting, 354 N.W.2d 706, 708 (N.D.1984). In determining whether or not the Heidts are entitled to injunctive relief, we do not examine the merits of their alleged defense. Our function is to examine the procedural entitlements set forth by the Legislature. Foreclosure by advertisement is entirely a legislative pronouncement. Section 35-22-01, N.D.C.C., provides that a real property mortgage executed to the Bank of North Dakota may be foreclosed upon by advertisement. While the Legislature allows the Bank of North Dakota to proceed in this manner rather than by an action to foreclose in some cases, it has placed some limitations on the process. One of the limitations on foreclosure by advertisement is delineated in § 35-22-04, N.D.C.C. Section 35-22-04 sets forth the method by which a mortgagor may enjoin foreclosure by advertisement. This statute, codified in 1883 at § 597 of the Code of Civil Procedure, Revised Codes of Dakota, provided:

"FORECLOSURE BY ADVERTISEMENT
"597. Power of sale. Every mortgage of real property containing therein a power of sale, upon default being made in the condition of such mortgage, may be foreclosed by advertisement in the cases and manner hereinafter specified: provided, that when the mortgagee or his assignee has commenced procedure by advertisement, and it shall be made to appear by the affidavit of the mortgagor, his agent or attorney, to the satisfaction of the judge of the district court of the county where the mortgaged property is situated, that the mortgagor has a legal counter-claim or any other valid defense against the collection of the whole or any part of the amount claimed to be due on such mortgage, such judge may, by an order to that effect, enjoin the mortgagee or his assignee from foreclosing such mortgage by advertisement, and direct that all further proceedings for the foreclosure be had in the district court properly having jurisdiction of the subject-matter; and for the purpose of carrying out the provisions of this act, service may be made upon the attorney or agent of the mortgagee or assignee. (As *859 amended, Sess.Laws 1883, c. 61[1].)" [Emphasis in original.]
In 1931 the Legislature amended the above section,[2] and, with minor alterations thereafter, the section now provides as follows:

"35-22-04. Foreclosure by advertisement enjoinedProcedure. When the mortgagee or his assignee has served notice of intention to foreclose a mortgage, and within the period provided by such notice it shall be made to appear by the affidavit of the mortgagor, or any person claiming under him, or his agent or attorney, to the satisfaction of a judge of the district court of the county where the mortgaged property is situated, that the mortgagor has a legal counterclaim or any other valid defense against the collection of the whole or any part of the amount claimed to be due on such mortgage, which proof must be made by affidavit stating the facts, but not on information and belief, such judge, by an order to that effect, may enjoin the mortgagee or his assignee from foreclosing the mortgage by advertisement and may direct that all further proceedings for the foreclosure thereof be had in the district court having jurisdiction of the subject matter. After the expiration of the period provided by the notice of intention, an order enjoining the foreclosure by advertisement shall be made only on motion or order to show cause. Notice of such motion, together with the affidavit used in support thereof, shall be served upon the attorney or agent of the mortgagee or assignee in the same manner as service of other notices of motion, not less than eight days before the hearing thereon. The affidavit in support of the motion shall state the facts upon which the application is made, shall not be on information and belief, and shall disclose a legal counterclaim or other valid defense to the collection of the whole or some part of the amount claimed to be due on the mortgage. Upon the hearing of the motion, the judge may enjoin the foreclosure of the mortgage by advertisement in the same manner as if the application had been made ex parte within the period of the notice of intention to foreclose. Service of the restraining order may be made upon the attorney or agent of the mortgagee or assignee, if the order was obtained ex parte, or if obtained on motion or order to show cause, it may be served upon the attorney or agent or upon the sheriff of the county where the foreclosure sale is to be had. If the notice of intention does not disclose the address of a resident agent or attorney, the order may be served upon such sheriff." [Emphasis added.]
In amending this section, the Legislature distinguished the requirements for obtaining an injunction within the period provided by the notice of intention to foreclose[3] and the requirements for obtaining an injunction after the period has expired. If the mortgagor's affidavit is filed within 30 days of the notice of intention to foreclose, the granting of an injunction is virtually automatic in an ex parte proceeding upon the presentation of a legal counterclaim or any other valid defense to the mortgage foreclosure.
The procedure for obtaining an injunction changes, however, once the 30-day period has expired. After the expiration of the 30-day period, an injunction is issued *860 only upon motion or order to show cause. The Legislature has specifically directed that a hearing shall be held in this instance. § 35-22-04, N.D.C.C. The rationale for the distinction between these two processes is not entirely clear. However, a possible interpretation of the Legislature's action is that during the 30-day notice period a mortgagor is entitled to comply with the terms of the mortgage, thereby reinstating the mortgage and preventing foreclosure. The mortgagee Bank is unable to proceed with the sale until these 30 days have passed. Therefore, prior to the expiration of the 30 days, the Bank is not harmed by the issuance of an injunction. Once the 30 days have expired, however, the Bank will suffer because it has begun preparation for the sale.
Of critical importance to this case and all future cases in which the "confiscatory price defense" is asserted is: What type of hearing was contemplated by the Legislature in enacting § 35-22-04? The Legislature has not spelled out the parameters which should guide a court in entertaining a motion to enjoin.
The Heidts assert that our recent decision in Folmer v. State, 346 N.W.2d 731 (N.D.1984), implies that a hearing is not required, contrary to the directive of § 35-22-04. The Folmer decision was not intended to abrogate the hearing requirement of § 35-22-04 on the narrow issue of whether or not the affidavit in support of the petition for an injunction of the foreclosure by advertisement raises "a legal counterclaim or other valid defense" to an action to foreclose. In Folmer we declined to remand for a hearing on that issue because we had found as a matter of law that the defense asserted in Folmer was a proper legal defense and the trial court had conceded that, if the defense had been pleaded in an action to foreclose, it would have justified an injunction. Our discussion in Folmer, supra, of the procedural aspects of enjoining a foreclosure by advertisement emphasizes the strong policy purpose behind § 35-22-04. The purpose is, of course, to allow a mortgagor who alleges a defense or counterclaim to have his cause thereafter determined in a formal judicial proceeding. Larson v. Jacobson, 54 N.D. 69, 208 N.W. 833 (1926). As we stated in Folmer, "[f]oreclosure by advertisement is merely a legal `short cut' which is authorized when there is no purpose to be served by judicial intervention." 346 N.W.2d at 735.
The court emphasized in Folmer, supra, that the only issue which is before the district court on a motion to enjoin is whether or not a defense or legal counterclaim exists. It is not the district court's function at the hearing to determine whether or not the cost of production exceeds the market prices for farm products. The purpose of the hearing is not to delve into the merits of the case. The merits are reserved for the action to foreclose.
The district court in the instant case made determinations on the merits of the instant case contrary to Folmer and preceding case law. The district court formally adopted its oral ruling from the bench as its findings of fact and conclusions of law. In its ruling, the court concluded that "there is nothing in this record to me that would establish that there is any general economic or farm emergency as programs envisioned by the totality of the statute". A determination of whether or not a farm emergency exists constitutes the merits of the case. We conclude that the district court abused its discretion in reaching the merits of the case when examining the Heidts' motion to enjoin the foreclosure.
The Heidts contend that, pursuant to Folmer, the district court erred in allowing the State to introduce counter affidavits. We agree. We are cognizant of the special recognition the Legislature has given to the depressed state of the farm economy in enacting the "confiscatory price defense" contained in §§ 28-29-04, 28-29-05, and 28-29-06, N.D.C.C. Thus, we conclude that, where a mortgagor has alleged the "confiscatory price defense", he is entitled to an injunction as a matter of law, thereby forcing the mortgagee Bank to proceed by action. Counsel for the State argues that, *861 in providing for a hearing in § 35-22-04, the Legislature must have intended that the State could refute the contents of the mortgagor's affidavit. We think that the hearing provided under § 35-22-04 was intended to entertain not only the "confiscatory price defense" which we recognized in Folmer, but all types of defenses to a mortgage foreclosure. In a case where a defense or legal counterclaim other than the "confiscatory price defense" is asserted, it may be desirable to allow the mortgagee to submit counter affidavits. That question, however, is not before the court today.
Finally, the Heidts assert that the district court erroneously ruled that § 28-29-04, N.D.C.C., requires specific application to them. Section 28-29-04 provides:

"28-29-04. Power of courts when prices are confiscatory. Until the price of farm products produced in this state shall rise to a point to equal at least the cost of production, in comparison with the price of other commodities in general, entering into the business of agriculture, the supreme court of this state and all district and county courts in this state shall have power, when it is deemed for the best interests of litigants, to extend the time for serving and filing all papers requisite and necessary for the final determination of any cause. Any such court, in like manner, may stay the entry of judgment or the issuance of execution thereon, or may defer the signing of any order for judgment, or may defer terms of court, whenever in the judgment of the court the strictly legal procedure in any cause will confiscate or tend to confiscate the property of any litigant by forcing the sale of agricultural products upon a ruinous market."
The State contends that the Heidts must show that they possessed commodities or farm products at the time of the hearing in order to invoke § 28-29-04. We disagree. No reasonable interpretation of § 28-29-04 would require the possession of commodities in order to invoke the "confiscatory price defense". We look at the object of the legislative enactment. The "confiscatory price defense" was designed to protect the farmer-landowner. Requiring the farmer to possess commodities in order to invoke the defense contained in § 28-29-04 flies in the face of the statute's intended purpose. If the cost of production has indeed exceeded the market price of the products, it is likely that the farmer has been forced to sell any commodities he once had. According to the transcript, the Heidts' cattle had been sold prior to the hearing. They had no grain to sell at that time. Mr. Heidt, however, possessed a one-third interest in 80 head of cattle at the time of the hearing. We hold that the district court erroneously concluded as a matter of law that § 28-29-04 requires the Heidts to demonstrate possession of commodities or farm products at the time of the hearing as a prerequisite to invoking the "confiscatory price defense".
We conclude that the district court abused its discretion in denying the Heidts' motion to enjoin the foreclosure by advertisement. The district court's decision is therefore reversed. The case is remanded for entry of an order granting the injunction and for appropriate action in vacating the sale. The State is entitled to proceed with an action to foreclose, at which time the Heidts will be afforded a full trial on the merits of their defense to the action.
ERICKSTAD, C.J., and VANDE WALLE, LEVINE and MESCHKE, JJ., concur.
NOTES
[1]  This court has held that "the `confiscatory price defense' contained in Sections 28-29-04, 28-29-05, and 28-29-06 is a `legal counterclaim or other valid defense' which provides a sufficient basis to enjoin a foreclosure by advertisement pursuant to Section 35-22-04 .... Folmer v. State, 346 N.W.2d 731, 735 (N.D.1984).
[2]  S.L.1931, ch. 219, § 1.
[3]  The "period provided by the notice of intention to foreclose" will be at least 30 days in accordance with § 35-22-03, N.D.C.C., which provides, in pertinent part:

"35-22-03. Notice of intention to forecloseServicePaymentFailure to commence foreclosure within ninety days. Before any real estate mortgage may be foreclosed by advertisement, a notice of intention to foreclose such mortgage shall be served on the record title owner of the real estate described in the mortgage.... If the owner of the land or his legal representative, before the expiration of thirty days from the service of the notice of intention to foreclose the mortgage, shall perform or comply with the conditions of the mortgage, the mortgage shall remain in full force and effect the same as if no default had occurred...." [Emphasis added.]
