I am designing / creating a middle-level ASP.NET web application using the webform. The main work in the project is creating every web form, and I do not know how to design my controls (in a code / data / data flow sense).
I give you some examples of what I am doing, you can understand what I mean:
In the application, a normal work road Address is entered and displayed. So I created a user control called "knowfield" which contains a series of HtmlInputText elements (one for line 1, city / city, country, postal code etc.).
- zero show address (which fills HtmlInputText elements with proper text) In my DB institutions class is a class called "address"
- Update Ad (Address Adr) - which updates the content of ADR with the existing contents of HTML input text elements
- Address ad (address) - which creates a new instance of address and then sends it to the update address And then it comes back
now Till, very good This works because the AddressFields control is 'dumb' which displays all and retrieves data from the user. ViewStat HTML is handled directly by input text fields, so no additional logic is necessary.
There is another class "client" in my application which is an address attribute class, but this class also has some more complex aspects, for example a client has a series of tags (my 'Categories' in the app) which can be assigned. In this case, I have created a subclass of ASPN.NET checkbox list control.
I have created another user agent called "clientfold" which includes all required fields to display a client's information (including address-address control), but my checkbox named "checklist list" List sub-class is also included.
The problem here is that the category control needs to be provided to display data (but not on postback, because it uses the viewstate). In this case, I have a question: is it the responsibility to connect to the database and retrieve the category entry ?
Is this category control? (If yes, then in the life of control, does this interrogate the database? It can not be controlled under control. Because this happens after the arrival of the clientfield. Does it happen in the clientfield? (Again, where life span This happens because clientfold has a ShowClient (Client C) method, which is called in the page load. One option is to expose the Clasustist to the clientfield, so that The page can be directly accessed, but it is a violation of good software design. / P>
In my opinion, Category list is responsible for retrieving category entry data because all the class data should not be received if it is chosen by one particular client or by a particular client.
< Strong> When the classlist list has its own age In general, the question asks the database?
Generally override the OnInit method to populate the catalog, but the viewstate does not start working at that time, so you can access data from DB and PO Obtaining it will cover itself on each postback. If you want to trust the viewsto, set the InitComplete event handler of the page to the override on-line method and register and populate the CategoryList in the event handler Both the InInit Method and InitComplete events have been called / removed before event events.
Secure Override Zero OnInit (EventArgs e) {base.OnInit (e); Page.InitComplete + = new event handler (page_intervanced); } Zero Page_InitComplete (object sender, EventArgs e) {// retrieve data and populate control} Hope it helps
Comments
Post a Comment