In my ASP.NET MVC 4 Web application I have two Models:
- Blockthat has a property- Block LinkedBlock.
- BlockCollectionwhich contains multiple- Block. Every- Blockinstance in- Block.LinkedBlockis guaranteed to be also in the- BlockCollection.
Now, what I want to do is the following:
If a Block has a linked block it should get a onchange handler that sets the text of the linked block to the text of this block.
Now, in principle, this is pretty simple:
if (Model.LinkedBlock != null)
{
    var onChange = string.Format("setText({0}, this.text);", linkedBlockId);
    @Html.TextBoxFor(m => m.Text, new { onchange = onChange });
}
<script type="text/javascript" language="javascript">
    function setText(id, text) {
        $("#" + id).val(text);
    }
But the problem is, that I have no idea how to get the correct HTML ID of the linked block.
How do I get it?
 
     
    