Interview questions

.Net - how to create a user control

Next question>>           Learn .NET
.Net - Explain with code sample how to create a user control. - June 03, 2009 at 11:00 AM by Shuchi Gauri

Explain with code sample how to create a user control.

Steps to create a User control:

a. Select a project
b. Right click and add a new item (User Control - .ascx) to the selected project.
c. Add @Control Directive
d. Add all the controls that you want to be displayed on the User control as a part of one or more web pages.
e. Write the code for all the tasks to be performed by the user control.
f. Create accessor methods for the outside world accessing this user control.

Using the User control:

Register the control on the webpage it needs to be used by putting @Register directive.

Specify the following attributes to the register directive:
a. TagPrefix: defines the namespace in which the control would reside
b. TagName: defines the name with which control is referred
c. Src: Path of where the control is kept.

Control is then used on the page using the following code:
<TagPrefix:TagName />

Next question>>

Also read

Explain how to implement Fragment Cache

Fragment cache is to store user controls individually within a web form in cache instead of the whole webform as such. The idea is to simply have different cache parameters for different user controls...........

What is Fragment Caching in ASP.NET?

Fragment caching refers to the caching of individual user controls within a Web Form, Each user control can have independent cache durations and implementations of how the caching behavior is to be applied................

Describe the different types of user-authored controls in NET.

User authored controls are which not part of the .net framework library. It includes both custom controls and user controls.........

Explain with code sample how to create an inherited control.

Steps to create inherited Control:-......... 



Write your comment - Share Knowledge and Experience


 

 
Latest placement tests
Latest links
 
Latest MCQs
» General awareness - Banking » ASP.NET » PL/SQL » Mechanical Engineering
» IAS Prelims GS » Java » Programming Language » Electrical Engineering
» English » C++ » Software Engineering » Electronic Engineering
» Quantitative Aptitude » Oracle » English » Finance
Home | About us | Sitemap | Contact us | We are hiring