Syncfusion ASP.NET MVC Inline AI Assist
The Inline AI Assist control provides AI-powered text processing within ASP.NET MVC applications. It renders as a floating popup anchored to a trigger element, supporting prompt input, response display, command shortcuts, and toolbar customization.
Quick Start Example
@using Syncfusion.EJ2.InteractiveChat
<div style="height: 350px; width: 650px;">
<button id="aiBtn" class="e-btn e-primary" Assist</button>
@Html.EJS().InlineAIAssist("myAssist")
.RelateTo("#aiBtn")
.Created("onCreated")
.PromptRequest("onPromptRequest")
.ResponseSettings(new Syncfusion.EJ2.InteractiveChat.InlineAIAssistResponseSettings {
ItemSelect = "onItemSelect"
})
.Render()
</div>
<script>
var inlineAssist;
function onCreated() { inlineAssist = this; }
function onPromptRequest(args) {
setTimeout(function () {
inlineAssist.addResponse('Your AI response here.');
}, 1000);
}
function onItemSelect(args) {
if (args.command.label === 'Accept') {
document.getElementById('content').innerHTML = inlineAssist.prompts[inlineAssist.prompts.length - 1].response;
inlineAssist.hidePopup();
} else if (args.command.label === 'Discard') {
inlineAssist.hidePopup();
}
}
function onBtnClick() {
if (inlineAssist) inlineAssist.showPopup();
}
</script>
public ActionResult Index()
{
return View();
}
Documentation and Navigation Guide
Getting Started & Core Setup
📄 Read: references/getting-started.md
When user needs to:
- Install NuGet package, register namespace, add CDN stylesheet/script
- Configure
RelateTo (anchor element) or Target (append container)
- Switch between
Popup and Inline response display modes
- Set up the script manager in
_Layout.cshtml
Inline Assist Configuration
📄 Read: references/inline-assist-config.md
When user needs to:
- Set default
Prompt text or pre-load Prompts collection with prior conversations
- Customize
Placeholder, PopupWidth, PopupHeight, ZIndex
- Apply custom CSS via
CssClass
Commands & Response Settings
📄 Read: references/commands-and-response.md
When user needs to:
- Add a command popup (
CommandSettings) with grouped shortcut actions
- Configure command item properties: label, prompt, iconCss, groupBy, tooltip, disabled
- Control command popup dimensions (
PopupWidth, PopupHeight)
- Handle
ItemSelect event on command selection
- Customize the response action popup (
ResponseSettings) with built-in or custom items
- Group response items, disable items, handle response
ItemSelect
Toolbar & Templates
📄 Read: references/toolbar-and-templates.md
When user needs to:
- Add custom items to the inline toolbar (
InlineToolbarSettings)
- Configure toolbar item properties: type, iconCss, text, align, tooltip, cssClass, disabled, visible
- Set toolbar position (
Inline or Bottom)
- Embed a custom widget (dropdown, input) via
Template (type: Input)
- Replace the footer editor with
EditorTemplate
- Customize response display with
ResponseTemplate
Methods & Events
📄 Read: references/methods-and-events.md
When user needs to:
- Call
addResponse, executePrompt programmatically
- Show/hide the main popup:
showPopup, hidePopup
- Show/hide the command popup:
showCommandPopup, hideCommandPopup
- Handle lifecycle events:
created, promptRequest, open, close
| Event |
Trigger |
Created |
Component rendering is complete |
PromptRequest |
User submits a prompt (or executePrompt is called) |
Open |
The popup is opened |
Close |
The popup is closed |
Globalization
📄 Read: references/globalization.md
When user needs to:
- Localize UI strings (send button, stop responding, thinking indicator)
- Enable RTL layout with
EnableRtl
Key Properties at a Glance
| Property |
Type |
Purpose |
RelateTo |
string / HTMLElement |
Anchor element for popup positioning |
Target |
string / HTMLElement |
Container element where popup appends |
ResponseMode |
string |
Popup (default) or Inline |
Prompt |
string |
Default prompt text |
Prompts |
array |
Pre-loaded prompt-response collection |
Placeholder |
string |
Textarea placeholder (default: Ask or generate AI content..) |
PopupWidth |
string |
Popup width (default: 400px) |
PopupHeight |
string |
Popup height (default: auto) |
ZIndex |
int |
Popup z-index (default: 1000) |
CssClass |
string |
Custom CSS class on popup |
EnableRtl |
bool |
Right-to-left layout |
Locale |
string |
Culture code for localization |
CommandSettings |
object |
Command popup configuration |
ResponseSettings |
object |
Response action popup configuration |
InlineToolbarSettings |
object |
Inline toolbar items and position |
EditorTemplate |
string |
Custom footer/editor area template |
ResponseTemplate |
string |
Custom response item template |
Common Patterns
Pattern 1 — Connect to a Real AI Service
In onPromptRequest, call your AI endpoint and pass the result to addResponse:
function onPromptRequest(args) {
fetch('/api/ai', {
method: 'POST',
body: JSON.stringify({ prompt: args.prompt }),
headers: { 'Content-Type': 'application/json' }
})
.then(r => r.json())
.then(data => inlineAssist.addResponse(data.response));
}
Pattern 2 — Apply Accepted Response to DOM
function onItemSelect(args) {
if (args.command.label === 'Accept') {
var editable = document.getElementById('editableText');
editable.innerHTML = '<p>' + inlineAssist.prompts[inlineAssist.prompts.length - 1].response + '</p>';
inlineAssist.hidePopup();
} else if (args.command.label === 'Discard') {
inlineAssist.hidePopup();
}
}
Pattern 3 — Get Component Instance
Always capture this in the Created event; all method calls require this reference:
var inlineAssist;
function onCreated() { inlineAssist = this; }
1---2name: syncfusion-aspnetmvc-inline-ai-assist3description: Implement Syncfusion ASP.NET MVC Inline AI Assist control. Use when building AI-powered inline text editing, prompt-response UIs, command popups, toolbar customization, response actions, and localization in ASP.NET MVC Razor views. Triggers when user needs to integrate InlineAIAssist, configure CommandSettings, ResponseSettings, InlineToolbarSettings, EditorTemplate, ResponseTemplate, or call methods like addResponse, executePrompt, showPopup, hidePopup in ASP.NET MVC applications.4---56# Syncfusion ASP.NET MVC Inline AI Assist78The Inline AI Assist control provides AI-powered text processing within ASP.NET MVC applications. It renders as a floating popup anchored to a trigger element, supporting prompt input, response display, command shortcuts, and toolbar customization.910## Quick Start Example1112```razor13@using Syncfusion.EJ2.InteractiveChat1415<div style="height: 350px; width: 650px;">16 <button id="aiBtn" class="e-btn e-primary" onclick="onBtnClick()">AI Assist</button>1718 @Html.EJS().InlineAIAssist("myAssist")19 .RelateTo("#aiBtn")20 .Created("onCreated")21 .PromptRequest("onPromptRequest")22 .ResponseSettings(new Syncfusion.EJ2.InteractiveChat.InlineAIAssistResponseSettings {23 ItemSelect = "onItemSelect"24 })25 .Render()26</div>2728<script>29 var inlineAssist;3031 function onCreated() { inlineAssist = this; }3233 function onPromptRequest(args) {34 setTimeout(function () {35 inlineAssist.addResponse('Your AI response here.');36 }, 1000);37 }3839 function onItemSelect(args) {40 if (args.command.label === 'Accept') {41 document.getElementById('content').innerHTML = inlineAssist.prompts[inlineAssist.prompts.length - 1].response;42 inlineAssist.hidePopup();43 } else if (args.command.label === 'Discard') {44 inlineAssist.hidePopup();45 }46 }4748 function onBtnClick() {49 if (inlineAssist) inlineAssist.showPopup();50 }51</script>52```5354```csharp55public ActionResult Index()56{57 return View();58}59```6061---6263## Documentation and Navigation Guide6465### Getting Started & Core Setup66📄 **Read:** [references/getting-started.md](references/getting-started.md)6768When user needs to:69- Install NuGet package, register namespace, add CDN stylesheet/script70- Configure `RelateTo` (anchor element) or `Target` (append container)71- Switch between `Popup` and `Inline` response display modes72- Set up the script manager in `_Layout.cshtml`7374### Inline Assist Configuration75📄 **Read:** [references/inline-assist-config.md](references/inline-assist-config.md)7677When user needs to:78- Set default `Prompt` text or pre-load `Prompts` collection with prior conversations79- Customize `Placeholder`, `PopupWidth`, `PopupHeight`, `ZIndex`80- Apply custom CSS via `CssClass`8182### Commands & Response Settings83📄 **Read:** [references/commands-and-response.md](references/commands-and-response.md)8485When user needs to:86- Add a command popup (`CommandSettings`) with grouped shortcut actions87- Configure command item properties: label, prompt, iconCss, groupBy, tooltip, disabled88- Control command popup dimensions (`PopupWidth`, `PopupHeight`)89- Handle `ItemSelect` event on command selection90- Customize the response action popup (`ResponseSettings`) with built-in or custom items91- Group response items, disable items, handle response `ItemSelect`9293### Toolbar & Templates94📄 **Read:** [references/toolbar-and-templates.md](references/toolbar-and-templates.md)9596When user needs to:97- Add custom items to the inline toolbar (`InlineToolbarSettings`)98- Configure toolbar item properties: type, iconCss, text, align, tooltip, cssClass, disabled, visible99- Set toolbar position (`Inline` or `Bottom`)100- Embed a custom widget (dropdown, input) via `Template` (type: Input)101- Replace the footer editor with `EditorTemplate`102- Customize response display with `ResponseTemplate`103104### Methods & Events105📄 **Read:** [references/methods-and-events.md](references/methods-and-events.md)106107When user needs to:108- Call `addResponse`, `executePrompt` programmatically109- Show/hide the main popup: `showPopup`, `hidePopup`110- Show/hide the command popup: `showCommandPopup`, `hideCommandPopup`111- Handle lifecycle events: `created`, `promptRequest`, `open`, `close`112113| Event | Trigger |114|-------|---------|115| `Created` | Component rendering is complete |116| `PromptRequest` | User submits a prompt (or `executePrompt` is called) |117| `Open` | The popup is opened |118| `Close` | The popup is closed |119120### Globalization121📄 **Read:** [references/globalization.md](references/globalization.md)122123When user needs to:124- Localize UI strings (send button, stop responding, thinking indicator)125- Enable RTL layout with `EnableRtl`126127---128129## Key Properties at a Glance130131| Property | Type | Purpose |132|---|---|---|133| `RelateTo` | string / HTMLElement | Anchor element for popup positioning |134| `Target` | string / HTMLElement | Container element where popup appends |135| `ResponseMode` | string | `Popup` (default) or `Inline` |136| `Prompt` | string | Default prompt text |137| `Prompts` | array | Pre-loaded prompt-response collection |138| `Placeholder` | string | Textarea placeholder (default: `Ask or generate AI content..`) |139| `PopupWidth` | string | Popup width (default: `400px`) |140| `PopupHeight` | string | Popup height (default: `auto`) |141| `ZIndex` | int | Popup z-index (default: `1000`) |142| `CssClass` | string | Custom CSS class on popup |143| `EnableRtl` | bool | Right-to-left layout |144| `Locale` | string | Culture code for localization |145| `CommandSettings` | object | Command popup configuration |146| `ResponseSettings` | object | Response action popup configuration |147| `InlineToolbarSettings` | object | Inline toolbar items and position |148| `EditorTemplate` | string | Custom footer/editor area template |149| `ResponseTemplate` | string | Custom response item template |150151---152153## Common Patterns154155### Pattern 1 — Connect to a Real AI Service156In `onPromptRequest`, call your AI endpoint and pass the result to `addResponse`:157```javascript158function onPromptRequest(args) {159 fetch('/api/ai', {160 method: 'POST',161 body: JSON.stringify({ prompt: args.prompt }),162 headers: { 'Content-Type': 'application/json' }163 })164 .then(r => r.json())165 .then(data => inlineAssist.addResponse(data.response));166}167```168169### Pattern 2 — Apply Accepted Response to DOM170```javascript171function onItemSelect(args) {172 if (args.command.label === 'Accept') {173 var editable = document.getElementById('editableText');174 editable.innerHTML = '<p>' + inlineAssist.prompts[inlineAssist.prompts.length - 1].response + '</p>';175 inlineAssist.hidePopup();176 } else if (args.command.label === 'Discard') {177 inlineAssist.hidePopup();178 }179}180```181182### Pattern 3 — Get Component Instance183Always capture `this` in the `Created` event; all method calls require this reference:184```javascript185var inlineAssist;186function onCreated() { inlineAssist = this; }187```