Comments (3)
You could call the renderer API from a Razor View if you want to inject the HTML in it. I don't have a code sample but it should be relatively straight forward using Razor's docs to call APIs
Please see here for a C# sample: https://docs.microsoft.com/en-us/adaptive-cards/sdk/rendering-cards/net-html/render-a-card
Please let us know if that doesn't answer your question
from adaptivecards.
This documentation shows how to create the html in the c# class but not how to display it on the page. The Razor documentation is not helpful either. Just adding the razor page to this example in the documentation would be extremely helpful.
Edit: Update on previous comment - code example
I have tried this code both in the razor page as shown here, and with the code in a C# class, adding the rendered html to a ViewData object and displaying that on the razor page. Both give the same result. I only see the adaptive card as a string with the html tags.
What is missing between creating the renderer.RenderCard(card)
and using it on the page?
@page
@using AdaptiveCards
@using AdaptiveCards.Rendering.Html
@model ScoutAdaptiveCardRenderer.Pages.Card.CardRenderModel
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@{
ViewData["Title"] = "CardRender";
}
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
@{
AdaptiveCardRenderer renderer = new AdaptiveCardRenderer();
AdaptiveCard card = new AdaptiveCard(renderer.SupportedSchemaVersion);
card.Body.Add(new AdaptiveTextBlock { Text = "Hello World" });
AdaptiveTextInput adaptiveTextInput = new AdaptiveTextInput { IsMultiline = true };
card.Body.Add(adaptiveTextInput);
AdaptiveActionSet adaptiveActionSet = new AdaptiveActionSet();
adaptiveActionSet.Actions.Add(new AdaptiveOpenUrlAction()
{
Id = "buttonId",
Title = "Button"
});
card.Body.Add(adaptiveActionSet);
RenderedAdaptiveCard renderedCard = renderer.RenderCard(card);
}
@renderedCard.Html
</body>
</html>
from adaptivecards.
@PeggyWiltz I believe you need to wrap this line:
@renderedCard.Html
In the raw HTML helper that Razor provides as follows:
@Html.Raw(renderedCard.Html)
You can review the docs for this method here: https://docs.microsoft.com/en-us/dotnet/api/system.web.mvc.htmlhelper.raw?view=aspnet-mvc-5.2
from adaptivecards.
Related Issues (20)
- Typo Error "the" HOT 1
- Jj
- Microsoft TenantId missing in request payload when sent from Outlook in Universal Action Model(Action.Execute) HOT 1
- [Doc-Bug] Opening task module from outlook actionable messages is not supported
- [Doc-Enhancement] Adaptive card size limit in outlook
- I'm assuming this is dead
- Link to Interactive card visualizer no longer works
- Does 'Outlook Actionable Message' support version 1.4?
- Typo in "StatucCode" in the document
- Update Tools Section
- The sample doesn't work "talk to our Scuba"
- mm
- Expired certificate HOT 1
- Deprecated package HOT 2
- S
- RFC 3389 is mislabeled
- Carousel Issue
- Response format table does not have link and have TODO:
- Error in Action code for SubmitAction
- Link to Youtube broken
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from adaptivecards.