I am new to usercontrols by creating only one, so bear with me. Today I read that usercontrols should be autonomous and not rely on any information from the parent container. I get this part, but what I find difficult to understand is the "right" way to develop my program on this principle.
I am making a web form in C # where there is a page with usercontrol on that page. I made usercontrol in its ascx file and dragged it onto my aspx page. Usercontrol is a pair of dates and a gridview to display the results of an SQL stored procedure.
I would really like to reuse this control, but I canβt understand how to βtellβ usercontrol what stored procedure I want to run for the specific page on which I am, without breaking the βdonβ, t rely on the rule of the parent container.
thanks
Do not rely on the parent container, this does not mean that you can not communicate. Select the property in the user control that will be set by the parent. But have a default value so that it doesn't work.
, , , . , .
, . - . , , - , . , . , . , , , , , , , .
, . , .
, , gridview . , , , , , , , .
, , , . , , , .
, -, .
, , , ?
: , , , .
, , , proc.
, . , , , (MyPage.aspx) .
, , - . . - .
( ) . , EventArgs, ( DateTime). , ( EventHandler<YourEventArgs>) EventArgs. , , , .
DateTime
EventHandler<YourEventArgs>
EventArgs
, , . . UI . (AddRecord.aspx UpdateRecord.aspx). , , , .
, . / . .
"tell" usercontrol which stored procedure I want to run
It looks like you are looking for events / delegatesAsk the control to set the event and let the parent add a handler (perhaps to the constructor if you want to force it to add one and only one event)Alternatively, you can use the Command / Strategy template - the parent encapsulate method and send the encapsulating object to the control in its constructor.
Source: https://habr.com/ru/post/1707714/More articles:Windows Form Inheritance - inheritanceFind and Replace in Visual Studio 2008 will slow down - visual-studio-2008PHP errors on cronjob, works great when prompted - linuxhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1707712/ms-access-mdb-split-memo-field-into-several-text-fields-to-prevent-data-corruption&usg=ALkJrhjWj9cTUAFi9AgfsV3edh4x1REuWQLogical Expression Parser - expressionAccess the Blackberry Media Directory in JDK - filesystemsHas anyone got a Recaptcha to run on the Google App Engine (in Java)? - javaHow to save and delete a bitmap in Blackberry Storm? - file-ioMicrosoft SQL Server Statistics via ODBC - ruby ββ| fooobar.comPointer array length - cAll Articles