Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

New asp "showat" attribute required inconsistently in VS2010. Why?

When I generate code using T4 templates in Visual Studio 2010, I get the following error for each of my asp controls when I try to compile:

Control "ddState" is missing required attribute "showat".

I have never gotten this error in previous versions of .NET. Further, I don't get this error when I manually construct my pages either by dragging/dropping, nor do I get it when I type out the control text myself. When I generate code, I have to manually add showat="client" to my tag for the compiler to be happy. It was my understanding that I never had to explicitly specify this tag. The following:

<asp:dropdownlist id="ddState" runat="server" showat="client" />

solves the problem. Why do I have to add this to generated code but not other times?

(It's a VS-2010 webforms project, using VB, in case that makes a difference.)

like image 398
Patrick Karcher Avatar asked Jan 22 '23 08:01

Patrick Karcher


2 Answers

Apparently .NET 5 or another one of those super service packs is going to allow something called targeted rendering. It was originally intended for use just in the context of webforms, but I've heard recently there will be some fancy way to use it in MVC (using some helper classes) and in services using WCF. It will work well with Dynamic Data but is very loosely coupled with it; you can use one or the other completely independently. If you configure your dynamic data with certain tags you can have it constructed on the client, etc.

For now, just put showat="client" in all your tags, and all is good. That's supposed to be the implicit default, but I've heard of cases where the IDE seems to require it. In the future, showat="client" will be the safest setting anyway, giving the expected behavior in 99.9% of cases.

like image 83
Vivian River Avatar answered Jan 30 '23 04:01

Vivian River


This is required in VB, but not C#, which is why it seems to not be necessary sometimes. To be more specific, the C# compiler puts the equivalent of showat=client into the IL automatically, unless you specify a showat target other than client.

like image 25
kasabb Avatar answered Jan 30 '23 06:01

kasabb