.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Interview Question >> SharePoint >> Post New Question Subscribe to Interview Questions

What is difference between CreateChildControls and the RenderContents method.

Posted By :abhays     Posted Date :June 04, 2014    Points :40   Category :SharePoint 
The CreateChildControls method is used to add controls to the WebPart, and the RenderContents method is used to tell the page framework how to render the control into HTML to display on a page.

You can also find related Interview Question to What is difference between CreateChildControls and the RenderContents method.  below: 

What is the difference between Session.Clear() and Session.RemoveAll() method?

  
Well, actually there is no difference. Session.RemoveAll() methods internally makes a call to Clear() method only.

Thanks. (More...)

What is difference between TransferRequest and Transfer method?

  
Transfer: Terminates execution of the current page and starts execution of provided URL.
TransferRequest : Performs an asynchronous execution of the provided URL. (More...)

Main Difference between Method and function?

  
Method which tied to a class where as function need not to be. In OOPS we can say there is no functions concept because all the method is tied to a class.

Function is available in procedural language, Scripting language that why we say JavaScript function etc. (More...)

What is the difference between method activity and event activity in WorkFlow ?

  
A method activity is one that performs an action, such as creating or updating a task. An event activity is one that runs in response to an action occurring. (More...)

What is the CreateChildControls() method? How can you use it to do something simple like displaying a Label control?

  
The CreateChildControls method in WebParts is used to notify the WebPart that there are children controls that should be output for rendering. Basically, it will add any child ASP.NET controls that are called instantiating each control with its relevant properties set, wire any relevant event handlers to the control, etc. Then the add method of the control class will add the control to the controls collection. In the relevant WebPart render method, the EnsureChildControls method can be called (or set to false if no child controls should be called) to ensure that the CreateChildControls method is run. When using CreateChildControls it implies that your WebPart contains a composition of child controls. In order to create something like a label control in Create, you would create a new label control using the new keyword, set the various properties of the control like Visible=True and ForeColor = Color.Red, and then use Controls.Add(myLabelControl) to add the control to the controls collection. Then you can declare EnsureChildControls in the Render method of the WebPart. (More...)

What is the difference between Convert.toString and .toString()
method?

  
Just to give an understanding of what the above question means see the below code :-

int val = 0;
MessageBox.Show(val.ToString());
MessageBox.Show(Convert.ToString(val));


We can convert the integer "val" using "val.ToString()" or "Convert.ToString" so what's the difference.

The basic difference between them is "Convert" function handles NULLS while "val.ToString()"
does not.

It will throw a NULL reference exception error. So as good coding practice using "Convert" is always safe. (More...)

What is the difference between Convert.ToString() and .ToString() method.

  
Have a look at the following program and its output

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ExampleOfString
{
class Program
{
static void Main(string[] args)
{
String UserName = null ;
try
{
//Below statement WILL THROW an exception as .ToString() does not handles null values
String strUserId = UserName.ToString();
}
catch (NullReferenceException ex)
{
Console.WriteLine("Error:{0}", ex.Message);
}

try
{
//Below statement WILL NOT THROW an exception as convert.tostring handles implicitly
String strUserId = Convert.ToString(UserName);
Console.WriteLine("UserName:{0}", strUserId);
}
catch (NullReferenceException ex)
{
Console.WriteLine("Error:{0}", ex.Message);
}
}
}
}

/*
Below is the output of the console application

Error:Object reference not set to an instance of an object.
UserName:
Press any key to continue . . .
*/ (More...)

What is the difference between OrderBy() and Sort() method over IList

  
OrderBy() sorts and gives the view IEnumerable(). But underlying list is sorted or not changed.

Sort() modifies the underlying list. (More...)

What is the CreateChildControls() method? How can you use it to do something simple like displaying a Label control?

  
The CreateChildControls method in WebParts is used to notify the WebPart that there are children controls that should be output for rendering. Basically, it will add any child ASP.NET controls that are called instantiating each control with its relevant properties set, wire any relevant event handlers to the control, etc. Then the add method of the control class will add the control to the controls collection. In the relevant WebPart render method, the EnsureChildControls method can be called (or set to false if no child controls should be called) to ensure that the CreateChildControls method is run. When using CreateChildControls it implies that your WebPart contains a composition of child controls (More...)

What is the difference between method activity and event activity in WorkFlow ?


  

A method activity is one that performs an action, such as creating or updating a task. An event activity is one that runs in response to an action occurring (More...)

What is The Difference Between Final variable,method,class IN Java.

  
Final variable - Like Constant.
Final method - Can't overridden.
Final class - Can't Inherited by Any other Class (More...)

What is the CreateChildControls() method? How can you use it to do something simple like displaying a Label control?

  
The CreateChildControls method in WebParts is used to notify the WebPart that there are children controls that should be output for rendering. Basically, it will add any child ASP.NET controls that are called instantiating each control with its relevant properties set, wire any relevant event handlers to the control, etc. Then the add method of the control class will add the control to the controls collection. In the relevant WebPart render method, the EnsureChildControls method can be called (or set to false if no child controls should be called) to ensure that the CreateChildControls method is run. When using CreateChildControls it implies that your WebPart contains a composition of child controls.
In order to create something like a label control in Create, you would create a new label control using the new keyword, set the various properties of the control like Visible=True and ForeColor = Color.Red, and then use Controls.Add(myLabelControl) to add the control to the controls collection. Then you can declare EnsureChildControls in the Render method of the WebPart. (More...)

What does the RenderContents method do WebPart?

  
The render contents method will render the WebPart content to the writer, usually an HtmlTextWriter since WebParts will output to an HTML stream. RenderContents is used to tell how the controls that are going to be displayed in the WebPart should be rendered on the page. (More...)

What is the difference between convert.to.string and .to.string() method?

  
Convert function handles nulls while i.string() does not it will throw a null reference exception error. (More...)

Quick Links For Interview Questions Categories:
ASP.Net Windows Application   .NET Framework   C#   VB.Net   ADO.Net  
Sql Server   SharePoint   Silverlight   OOPs   JQuery   JavaScript/VBScript
Biztalk Patten/Practices .IIS WCF WPF WWF
Networking Aptitude Others   All      

Find questions, FAQ's and their answers related to .NET, C#, Vb.Net, Sql Server and many more.

 
Now you can find lots of .NET, C#, Vb.Net, SQL Server,Windows, ASP.Net related Questions and their Answers here at www.dotnetspark.com. Our aim is to help you pass your certification Exams (MCP, MCSD, MCAD etc.,) with flying scores and get good name in your company.

So, Start looking our Interview Question section daily and improve your .NET Skills. You can also help others by posting Interview Questions and their Answers in this section.


Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend