Partial User Control

In Asp.net web forms, why should user control be partial? I tried to remove the partial keyword and it says:

There is no partial modifier for the ad type "test"; another partial declaration of this type exists

Where is the other declaration?

I am trying to pass a generic type using a user control, how can I do this? I cannot, unless I change another declaration. I could not find it, so I deleted the partial keyword.

Note: you have 3 files if you do WebApplication, but if you only get 2 files on your website!

UserControl.ascx
UserControl.ascx.cs 

so is there another declaration on the site?


the reason why I want a generic one is because im creates a grid control, so I want to pass in the type that the data source will have.

+3
source share
4 answers

ASP.NET uses partial classes for the code because it must generate all the server-side controls that you declared in your ASPX file, the class, and merge all the other data files that come with your code name. This allows you to use ASP.NET classes to distribute across multiple files.

From MSDN :

class, partial (Partial in Visual Basic), , . , .

:

, ASP.NET , .aspx ; . . , , .

, ? , Type UserControl ?

+1

.

UserControl.ascx
UserControl.cs
UserControl.designer.cs

partial, partial.

+1

, , "". foo.designer.cs ( asp.net). , .

+1

They should not be partial, because I have never used a partial class for one. Some of the code generation tools will use partial so that they can change bits more easily based on the GUI that you do without you, and this happens to each other, but for the tools, not the code.

0
source

Source: https://habr.com/ru/post/1760438/


All Articles