且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用Razor在MVC中为div创建动态ID ...

更新时间:2022-12-20 16:48:00

好,知道了...问题是我只是非常确信它没有用,而实际上却有用.结果看起来不像预期的那样,但这不是使我确信它没有起作用的原因.但是我总是在Visual Studio的调试器中检查div的ID.结果是Visual Studio不会显示div的实际名称,而是显示未声明的div的代码.最后,当我检查浏览器中的元素时,id是正确的.

Ok, got it figured out... The problem was that I was only very convinced that it didn't work, while it actually worked. The result didn't look as expected, but that's not what convinced me that it didn't work. But I always checked the id of the div in the debugger inside visual studio... turns out that visual studio does not show the actual name of the div, but the uninterpreted code with which it was declared. The id when I examined the element in the browser was correct, in the end.

仅是我对整个Web领域还很陌生,在此之前我只使用C ++(非.NET),所以我还不知道所有内容在哪里以及它们的行为方式……这是一部分我猜是学习过程的一部分.

Only that I'm pretty new to this whole web-thing, exclusively working with C++ (non .NET) before now, so I don't yet know where all the things are and how they behave... it's part of the learning process I guess.

感谢您的回答.一旦我知道在哪里工作,他们都会工作.

Thanks for the answers. They all worked once I knew where to look if they work.

@dawidr:您的行缺少右括号,因此产生了错误.仔细查看后,我注意到了它;)

@dawidr: Your line was missing a closing bracket, so that's what produced the error. I noticed it once I took a closer look at it ;)