What are composite custom controls?
Composite custom controls combine one or more server or HTML controls within a single control class, which can be compiled along with other control classes to create an assembly (.dll) that contains a custom control library. Once created, the custom control library can be loaded into Visual Studio .NET and used in the same way as the standard server and HTML controls.
Composite custom controls are functionally similar to user controls, but they reside in their own assemblies, so you can share the same control among multiple projects without having to copy the control to each project, as you must do with user controls. However, composite controls are somewhat more difficult to create because you can’t draw them visually using the Visual Studio .NET Designer.
What are the steps to follow create and use a custom control in a Web application?
1. Create a solution containing a custom control project.
2. Add a Web application project to the solution, and set it as the startup project. You will use the Web application project to test the custom control during development.
3. Add a project reference from the Web application to the custom control project, and add an HTML @Register directive and control element to use the custom control on a Web form.
4. Create the custom control’s visual interface by adding existing controls to it through the custom control’s CreateChildControls method.
5. Add the properties, methods, and events that the custom control provides.
6. Build and test the custom control.
In general what is the base class for every composite custom control?
System.Web.UI.WebControls.WebControl
Which directive is used to add a custom control to a Web form?
Register directive.
What are the 3 Register directive's attributes?
TagPrefix
This name identifies the group that the user control belongs to. For example, the tag prefix for ASP.NET server controls is “asp”. You use this prefix to create a naming convention to organize your custom controls.
Namespace
This is the project name and namespace within the custom control assembly that contains the controls to register. Microsoft Visual Basic .NET uses the project name as an implicit namespace, so for controls written in Visual Basic .NET, use the project name.
Assembly
This is the name of the assembly (.dll) containing the custom controls. The control assembly must be referenced by the Web application. Referencing the assembly maintains a copy of it in the Web application’s /bin directory.
What are the differences between User Controls and Custom Controls?
1. User Controls are easy to create where as Custom Controls are difficult to create.
2. User Controls cannot be compiled into an assembly, where as Custom Controls can be compiled into an assembly.
3. User Controls cannot be added to tool box, where as Custom controls can be added to the toolbox.
4. You need to have a copy of user control in every project where you want to use it, where as this is not the case with custom controls. You can install a single copy of the Web custom control in the global assembly cache and share it between applications, which makes maintenance easier.
5. User controls are used for reusing existing user interface elements and code, but are not useful for developing reusable components for multiple web applications.
Showing posts with label asp dot net question and answers for dataset. Show all posts
Showing posts with label asp dot net question and answers for dataset. Show all posts
ASP.NET Interview questions and answers for cascading style sheets
What are Cascading style sheets?
Cascading style sheets (CSS) collect and organize all of the formatting information applied to HTML elements on a Web form. Because they keep this information in a single location, style sheets make it easy to adjust the appearance of Web applications.
What are the 3 levels at which formatting can be applied with in a web application?
1. Styles can be defined in a style sheet file. Styles in a style sheet can be applied to all webforms referencing the style sheet.
2. You can also define styles in the page’s head element. These styles can be applied to all elements on the current page.
3. You can also define styles inline, in the HTML tag itself. Inline styles are applicable only to the HTML element in which these styles are defined.
Inline formatting takes precedence over local formatting, which, in turn, takes precedence over global formatting. These precedence rules are the reason style sheets are referred to as cascading.
What are the advantages of storing style definitions in a style sheet file (.css) rather than locally in each Web form or inline with each HTML element?
1. Formatting can be maintained in one location so that you make changes only once for an entire application.
2. Several sets of parallel formatting rules can be maintained in separate style sheets for formatting output on different devices or for different user needs. For example, an application might provide standard, enlarged-type, and printer-friendly style sheets that the user can select at run time.
3. In general, you should use page and inline styles only when you have a really good reason to override the global styles. Relying heavily on page and inline styles can make it difficult to maintain the formatting in a Web application.
What HTML element is used to reference a style sheet on webform?
To reference a style sheet on webform you must add a link element to the page’s head element, as shown below.
link href="Styles.css" type="text/css" rel="st"
What is the use of Style Builder?
Style Builder is used to change the appearance of any of the styles in a style sheet. Changes to the style sheet change the appearance of all Web forms that reference that style sheet.
How do you modify a style sheet using style builder?
To modify a style sheet using style builder, follow these steps:
1. Open the style sheet in Visual Studio. Visual Studio .NET displays the style definitions in the Document window and an outline of the style sheet in the Tool window
2. Select the style to modify from the Tool window. Visual Studio .NET displays the definition for that style in the Document window.
3. Right-click in the style definition or right-click the style in the Tool window, and select Build Style from the shortcut menu. Visual Studio .NET displays the Style Builder Wizard.
4. Use the Style Builder to compose the formatting that you want to add or modify in the selected style, and then click OK.
5. When you have finished, you’ll see that the Style Builder adds the new or modified style attributes to the style definition.
Can you apply styles using class names or element IDs?
Yes, Using class names allows you to apply a single style to a number of different elements or to style the same element differently, depending on how the element is used. Using element IDs allows you to apply a style to a unique element on one or more Web forms.
When you create a style rule for a class, Visual Studio .NET adds a style definition to the style sheet using a .classified identifier.
You apply the style class to HTML elements by using the class attribute. You apply the style to server controls by using the Cssclass attribute.
Can you change style sheets at run time?
Yes.
Cascading style sheets (CSS) collect and organize all of the formatting information applied to HTML elements on a Web form. Because they keep this information in a single location, style sheets make it easy to adjust the appearance of Web applications.
What are the 3 levels at which formatting can be applied with in a web application?
1. Styles can be defined in a style sheet file. Styles in a style sheet can be applied to all webforms referencing the style sheet.
2. You can also define styles in the page’s head element. These styles can be applied to all elements on the current page.
3. You can also define styles inline, in the HTML tag itself. Inline styles are applicable only to the HTML element in which these styles are defined.
Inline formatting takes precedence over local formatting, which, in turn, takes precedence over global formatting. These precedence rules are the reason style sheets are referred to as cascading.
What are the advantages of storing style definitions in a style sheet file (.css) rather than locally in each Web form or inline with each HTML element?
1. Formatting can be maintained in one location so that you make changes only once for an entire application.
2. Several sets of parallel formatting rules can be maintained in separate style sheets for formatting output on different devices or for different user needs. For example, an application might provide standard, enlarged-type, and printer-friendly style sheets that the user can select at run time.
3. In general, you should use page and inline styles only when you have a really good reason to override the global styles. Relying heavily on page and inline styles can make it difficult to maintain the formatting in a Web application.
What HTML element is used to reference a style sheet on webform?
To reference a style sheet on webform you must add a link element to the page’s head element, as shown below.
link href="Styles.css" type="text/css" rel="st"
What is the use of Style Builder?
Style Builder is used to change the appearance of any of the styles in a style sheet. Changes to the style sheet change the appearance of all Web forms that reference that style sheet.
How do you modify a style sheet using style builder?
To modify a style sheet using style builder, follow these steps:
1. Open the style sheet in Visual Studio. Visual Studio .NET displays the style definitions in the Document window and an outline of the style sheet in the Tool window
2. Select the style to modify from the Tool window. Visual Studio .NET displays the definition for that style in the Document window.
3. Right-click in the style definition or right-click the style in the Tool window, and select Build Style from the shortcut menu. Visual Studio .NET displays the Style Builder Wizard.
4. Use the Style Builder to compose the formatting that you want to add or modify in the selected style, and then click OK.
5. When you have finished, you’ll see that the Style Builder adds the new or modified style attributes to the style definition.
Can you apply styles using class names or element IDs?
Yes, Using class names allows you to apply a single style to a number of different elements or to style the same element differently, depending on how the element is used. Using element IDs allows you to apply a style to a unique element on one or more Web forms.
When you create a style rule for a class, Visual Studio .NET adds a style definition to the style sheet using a .classified identifier.
You apply the style class to HTML elements by using the class attribute. You apply the style to server controls by using the Cssclass attribute.
Can you change style sheets at run time?
Yes.
ASP.NET Interview questions and answers for building application
What are the 2 build options for an ASP.NET web application?
1. Debug
2. Release
What are the 3 levels at which we can have a configuration file for an ASP.NET web application?
1. At the web server level : The Machine.config file located in the Windows\Microsoft.NET\Framework\version\config directory. This sets the base configuration for all .NET assemblies running on the server.
2. At the application or web site level : The Web.config file located in the IIS root directory.This sets the base configuration for all Web applications and overrides settings in Machine.config.
3. In the sub directory of an application root folder : These settings override the settings in the root folder's web.config file.
What happens when you make changes to an application’s Web.config file?
When you make changes to an application’s Web.config file, IIS automatically restarts the application and applies the changes. This has the side effect of resetting current Application or Session state variables, which can adversely affect users.
What happens when you access the Web.config file from a browser?
For security reasons, you can’t access the Web.config file from a browser. If a user requests the Web.config file from your Web site, he or she will receive an "This type of page is not served" error message.
What happens when you access the Global.asax file from a browser?
For security reasons, you can’t access the Global.asax file from a browser. If a user requests the Global.asax file from your Web site, he or she will receive an "This type of page is not served" error message.
What are the steps to follow to host a web application on a web server?
1. Use IIS to set up a virtual folder for the application.
2. Copy the Web application to the virtual directory.
3. Add any shared .NET components to the server’s global assembly cache (GAC).
4. Set the security permissions on the server to allow the application to access required resources.
What are the 2 components that should be installed on a web server where, the ASP.NET web application runs?
ASP.NET Web applications run under IIS, so both IIS and the Microsoft .NET Framework must be installed on the server before that server can host Web applications.
What is the purpose of default start page in IIS?
A default page enables IIS to display a page if the user does not specify one in his or her request. For example, a user might make a request using only your domain name, such as http://www.cinterviews.blogspot.com/. If a default page is enabled, IIS will respond with http://www.cinterviews.blogspot.com/default.aspx.
Don’t confuse IIS default pages with the Web Forms application start page in Visual Studio .NET. Visual Studio .NET requires that you set a start page for each project so that the development environment knows which page to display first during debugging. This setting has no effect on the IIS default page settings.
How do you copy the COM component to the server and register?
COM components generally provide a setup program to install or remove them from the system. If the component doesn’t provide a setup program, you can copy it to the server and register it using the MFC RegSvr32.exe utility, as shown below:
RegSvr32 MyComname.dll
What is GAC?
GAC stands for Global Assembly Cache. The global assembly cache (GAC) is a special subfolder within the Windows folder that stores the shared .NET components.
What is the difference between weak-named .NET components and strong-named .NET components?
This difference is how the names are stored within the assembly. Weak names are not guaranteed to be unique and thus cannot be shared without potentially causing conflicts. Strong names are digitally signed and provide a public key that ensures there are no conflicts. Furthermore, .NET components with strong names can’t call unmanaged code (such as COM components) and thus avoid potential conflicts with dependencies.
Weak-named .NET components must be individually copied to the /bin directories of the Web applications where they are used. Strong-named .NET components can be copied into the server’s GAC
What is the account under which the ASP.NET worker process run?
By default, the ASP.NET worker process runs using the ASPNET account, which is created when you install the .NET Framework. This account has limited privileges, which can cause permission-denied errors if your application writes files or tries to read files outside the current Web application’s boundaries.
What are the 3 ways in which you can modify the additional permissions required by your application.?
1. Grant the ASPNET user access to the required files. To use this option, the server must be using the Windows NT file system (NTFS).
2. Change the group the ASPNET user belongs to.
3. Use impersonation to run the process as another user.
Why is it not a good idea to add ASPNET user to the Administrators group?
Adding the ASPNET user to the Administrators group gives your Web application full privileges on the server; however, it also poses a potential security risk because outside users might be able to manipulate your application to hack your server.
How do you impersonate the ASP.NET worker process?
To use impersonation to run the ASP.NET worker process as a user other than ASPNET, set the identity element’s impersonation attribute in the application’s Web.config file.
1. Debug
2. Release
What are the 3 levels at which we can have a configuration file for an ASP.NET web application?
1. At the web server level : The Machine.config file located in the Windows\Microsoft.NET\Framework\version\config directory. This sets the base configuration for all .NET assemblies running on the server.
2. At the application or web site level : The Web.config file located in the IIS root directory.This sets the base configuration for all Web applications and overrides settings in Machine.config.
3. In the sub directory of an application root folder : These settings override the settings in the root folder's web.config file.
What happens when you make changes to an application’s Web.config file?
When you make changes to an application’s Web.config file, IIS automatically restarts the application and applies the changes. This has the side effect of resetting current Application or Session state variables, which can adversely affect users.
What happens when you access the Web.config file from a browser?
For security reasons, you can’t access the Web.config file from a browser. If a user requests the Web.config file from your Web site, he or she will receive an "This type of page is not served" error message.
What happens when you access the Global.asax file from a browser?
For security reasons, you can’t access the Global.asax file from a browser. If a user requests the Global.asax file from your Web site, he or she will receive an "This type of page is not served" error message.
What are the steps to follow to host a web application on a web server?
1. Use IIS to set up a virtual folder for the application.
2. Copy the Web application to the virtual directory.
3. Add any shared .NET components to the server’s global assembly cache (GAC).
4. Set the security permissions on the server to allow the application to access required resources.
What are the 2 components that should be installed on a web server where, the ASP.NET web application runs?
ASP.NET Web applications run under IIS, so both IIS and the Microsoft .NET Framework must be installed on the server before that server can host Web applications.
What is the purpose of default start page in IIS?
A default page enables IIS to display a page if the user does not specify one in his or her request. For example, a user might make a request using only your domain name, such as http://www.cinterviews.blogspot.com/. If a default page is enabled, IIS will respond with http://www.cinterviews.blogspot.com/default.aspx.
Don’t confuse IIS default pages with the Web Forms application start page in Visual Studio .NET. Visual Studio .NET requires that you set a start page for each project so that the development environment knows which page to display first during debugging. This setting has no effect on the IIS default page settings.
How do you copy the COM component to the server and register?
COM components generally provide a setup program to install or remove them from the system. If the component doesn’t provide a setup program, you can copy it to the server and register it using the MFC RegSvr32.exe utility, as shown below:
RegSvr32 MyComname.dll
What is GAC?
GAC stands for Global Assembly Cache. The global assembly cache (GAC) is a special subfolder within the Windows folder that stores the shared .NET components.
What is the difference between weak-named .NET components and strong-named .NET components?
This difference is how the names are stored within the assembly. Weak names are not guaranteed to be unique and thus cannot be shared without potentially causing conflicts. Strong names are digitally signed and provide a public key that ensures there are no conflicts. Furthermore, .NET components with strong names can’t call unmanaged code (such as COM components) and thus avoid potential conflicts with dependencies.
Weak-named .NET components must be individually copied to the /bin directories of the Web applications where they are used. Strong-named .NET components can be copied into the server’s GAC
What is the account under which the ASP.NET worker process run?
By default, the ASP.NET worker process runs using the ASPNET account, which is created when you install the .NET Framework. This account has limited privileges, which can cause permission-denied errors if your application writes files or tries to read files outside the current Web application’s boundaries.
What are the 3 ways in which you can modify the additional permissions required by your application.?
1. Grant the ASPNET user access to the required files. To use this option, the server must be using the Windows NT file system (NTFS).
2. Change the group the ASPNET user belongs to.
3. Use impersonation to run the process as another user.
Why is it not a good idea to add ASPNET user to the Administrators group?
Adding the ASPNET user to the Administrators group gives your Web application full privileges on the server; however, it also poses a potential security risk because outside users might be able to manipulate your application to hack your server.
How do you impersonate the ASP.NET worker process?
To use impersonation to run the ASP.NET worker process as a user other than ASPNET, set the identity element’s impersonation attribute in the application’s Web.config file.
ASP.NET Interview questions and answers for dataset
ASP.NET Interview questions and answers for dataset
What is a DataSet?DataSet is an in-memory cache of data.
In which namespace is the DataSet class present?
System.Data
Can you add more than one table to a dataset?
Yes
Can you enforce constarints and relations on tables inside a DataSet?
Yes, the DataSet consists of a collection of DataTable objects that you can relate to each other with DataRelation objects. You can also enforce data integrity in the DataSet by using the UniqueConstraint and ForeignKeyConstraint objects.
What happens when you invoke AcceptChanges() method on a DataSet?
Invoking AcceptChanges() method on the DataSet causes AcceptChanges() method to be called on each table within the DataSet.
Both the DataRow and DataTable classes also have AcceptChanges() methods. Calling AcceptChanges() at the DataTable level causes the AcceptChanges method for each DataRow to be called.
When you call AcceptChanges on the DataSet, any DataRow objects still in edit-mode end their edits successfully. The RowState property of each DataRow also changes. Added and Modified rows become Unchanged, and Deleted rows are removed.
If the DataSet contains ForeignKeyConstraint objects, invoking the AcceptChanges method also causes the AcceptRejectRule to be enforced.
Is there a way to clear all the rows from all the tables in a DataSet at once?
Yes, use the DataSet.Clear() method to clear all the rows from all the tables in a DataSet at once.
What is the difference between DataSet.Copy() and DataSet.Clone()?
DataSet.Clone() copies the structure of the DataSet, including all DataTable schemas, relations, and constraints. Does not copy any data.
DataSet.Copy() copies both the structure and data.
How do you get a copy of the DataSet containing all changes made to it since it was last loaded?
Use DataSet.GetChanges() method
What is the use of DataSet.HasChanges() Method?
DataSet.HasChanges method returns a boolean true if there are any changes made to the DataSet, including new, deleted, or modified rows. This method can be used to update a DataSource only if there are any changes.
How do you roll back all the changes made to a DataSet since it was created?
Invoke the DataSet.RejectChanges() method to undo or roll back all the changes made to a DataSet since it was created.
What happnes when you invoke RejectChanges method, on a DataSet that contains 3 tables in it?
RejectChanges() method will be automatically invoked on all the 3 tables in the dataset and any changes that were done will be rolled back for all the 3 tables.
When the DataTable.RejectChanges method is called, any rows that are still in edit-mode cancel their edits. New rows are removed. Modified and deleted rows return back to their original state. The DataRowState for all the modified and deleted rows will be flipped back to unchanged.
What is the DataSet.CaseSensitive property used for?
When you set the CaseSensitive property of a DataSet to true, string comparisons for all the DataTables within dataset will be case sensitive. By default the CaseSensitive property is false.
What happnes when you invoke RejectChanges method, on a DataSet that contains 3 tables in it?
RejectChanges() method will be automatically invoked on all the 3 tables in the dataset and any changes that were done will be rolled back for all the 3 tables.
When the DataTable.RejectChanges method is called, any rows that are still in edit-mode cancel their edits. New rows are removed. Modified and deleted rows return back to their original state. The DataRowState for all the modified and deleted rows will be flipped back to unchanged.
What is the DataSet.CaseSensitive property used for?
When you set the CaseSensitive property of a DataSet to true, string comparisons for all the DataTables within dataset will be case sensitive. By default the CaseSensitive property is false.
Keywords
ado.net interview questions and answers for 8 years experience
asp.net mvc interview questions
dot net interview questions and answers for 8 years experience pdf
ado.net interview questions javatpoint
net interview questions for 2 years experience
ado.net interview questions codeproject
c# interview questions
net interview questions for 10 years experience
Subscribe to:
Posts (Atom)