# Javascript: ParagraphFormat.setKeepWithNext Method

> Sets whether paragraph is displayed on the same page as its following paragraph.

- **Product:** TX Text Control .NET Server
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 26.0
- **Path:** TX Text Control .NET Server > Reference > JavaScript API > Javascript: ParagraphFormat.setKeepWithNext Method
- **357 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/paragraphformat/setkeepwithnext-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/paragraphformat/setkeepwithnext-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/paragraphformat/setkeepwithnext-method/llms-full.txt

---

### Description

Sets whether paragraph is displayed on the same page as its following paragraph.

### Syntax

```javascript
<void> ParagraphFormat.setKeepWithNext(<boolean> keepWithNext, [<EmptyRequestCallback> callback], [<ErrorCallback> errorCallback])
```

### Parameters

| Parameter | Description |
|---|---|
| keepWithNext | Specifies whether paragraph is displayed on the same page as its following paragraph. |
| callback | Optional. Is called when the operation completed. |
| errorCallback | Optional. Is called when the operation failed with an error. |

### Examples

The following example demonstrates `ParagraphFormat.setKeepWithNext` in a practical document-editing workflow. It sets whether paragraph is displayed on the same page as its following paragraph.

```javascript
function onTxError(error) {
    console.error("TX Text Control error:", error.msg);
    error.handled = true;
}

TXTextControl.paragraphFormat.setKeepWithNext(
    true,
    function() {
        console.log("set keep with next completed.");
    },
    onTxError
);
```

---

## Nearby

- **Previous:** [Javascript: ParagraphFormat.setKeepLinesTogether Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/paragraphformat/setkeeplinestogether-method/llms-full.txt)
- **Next:** [Javascript: ParagraphFormat.setLeftIndent Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/paragraphformat/setleftindent-method/llms-full.txt)
