AI OnAI Off
The ID is in the ContentReference of the block, if you're using a controller and a view/viewmodel you want to cast the Block in the controller method to IContent e.g.
public override ActionResult Index(CachedBlock currentBlock)
{
var content = (IContent) currentBlock;
var id = content.ContentLink.ID;
// Set in viewmodel object
If you're using a controllerless block you can do the same in the View in some inline C# or a C# block at the top of the page.
Would you have a suggestion for an inline C# approach? My block does not have a controller.
Yes as I said in my reply on the last line it's the same code just put it in a C# code block at the top of the view and cast the model.
I have created a new block type, and I am working on editing it's corresponding view. I would like to be able to display the contentid of the block in my html so that I can work some magic using javascript.
How can I get the contentid of the block from within it's view?