Showing posts with label Daily Tips. Show all posts
Showing posts with label Daily Tips. Show all posts

Daily Tips- Tip #44 - How to exit c# applications?

Tuesday, December 29, 2009


You can exit using the following 2 static methods,
1. Environment.Exit(returnval)
2. Application.Exit()


www.codecollege.NET

Daily Tips- Tip #43 - What is the use of checked keyword in c# ?


it is used to apply range checking to an operation.


www.codecollege.NET

Daily Tips- Tip #42 - What is the shortcut key to bring up the Immediate window?

Wednesday, December 16, 2009


Ctrl + Alt + I.


www.codecollege.NET

Daily Tips- Tip #41 -How will you test memory leak in a .NET application?


using Perfmon.exe application.


www.codecollege.NET

Daily Tips- Tip #44 - How will you mark a method as obsolete?

Monday, December 14, 2009


//c#
[Obsolete("Call NewMethod instead")]
void OldMethod()
{

}


www.codecollege.NET

Daily Tips- Tip #43 - How will you mark a method as Non-CLSCompliant?


//c#
[CLSCompliant(false)]
public void MyMethod(0
{
}


www.codecollege.NET

Daily Tips- Tip #42 - How will you mark an assembly with CLSComplaint?


'VB


//C#
[assembly: CLSCompliant(true)>


www.codecollege.NET

Daily Tips- Tip #41 -What is the short-cut for uncommenting code ?


Ctrl + K, Ctrl + U


www.codecollege.NET

Daily Tips- Tip #40 -What is the Short-cut for commenting out the code?


Ctrl + K, Ctrl + C


www.codecollege.NET

Daily Tips- Tip #38 - What is the method in MS Exception Management Application Block which is used to publish exceptions?

Friday, December 11, 2009


ExceptionManager.Publish(ex);


www.codecollege.NET

Daily Tips- Tip #39 - How will you beging a running a standard application message loop on the current thread?


Application.Run(new Form1());


www.codecollege.NET

Daily Tips- Tip #37 - What is the best way to check for a null and an empty value in a string?


string mystr;
if (String.IsNullOrEmpty(mystr))


www.codecollege.NET

Daily Tips- Tip #36 - How to view trace details for a specific request?

Thursday, December 10, 2009


To view trace details for a specific request
1.Goto to Trace.axd in the root of your application.

For ex: if the URL for your application is http://localhost/myApplication, Goto http://localhost/myApplication/trace.axd to view the trace information for that application.

2.Select the View Details link for the specific request that you want to investigate.



www.codecollege.NET

Daily Tips- Tip #34 - How will you invoke Immediate window in Visual studio?

Monday, December 7, 2009


1. Open the command window in Visual Studio
2. Type “immed” To Execute statements


www.codecollege.NET

Daily Tips- Tip #35 - #region blocks


Enclose Methods and Interfaces in #region blocks so that it can be collapsed or expanded.


www.codecollege.NET

Daily Tips- Tip #33 - How will you detect the name of the browser using ASP.NET ?

Wednesday, October 7, 2009


You can find that using the following code (which detects whether it is IE)
if(Page.Request.Browser.Browser=="IE")
{
}



www.codecollege.NET

Daily Tips- Tip #32 - How can i copy the files in the debug folder to some other directory automatically using the Build macros?

Sunday, August 30, 2009


Add the following line of code to the Post build event in the project properties,
call copy $(ProjectDir)$(OutDir) c:\test\


www.codecollege.NET

Daily Tips- Tip #30 - How to access ViewState value of the previous page in the current page ?

Thursday, August 6, 2009


Previous page's information is stored in a property called PreviousPage and you can access it using the following code,
Page prePage = this.PreviousPage;
Label totalEmployees = prePage.FindControl("lblTotEmployees");
Response.Write(totalEmployees.Text);


www.codecollege.NET

Daily Tips- Tip #29 - How will you get the value of ASP.Net control in Javascript ?


You can call the ASP.NET control from Javascript using the document.getElementById method.
Ex:
Let txtEmployeeName be a Textbox, then
var tEmp = document.getElementById('<%=txtEmployeeName.ClientID%>');


www.codecollege.NET

An alternate to Javascript's document.getElementByid()?


You can use as an alternate to Javascript's document.getElementByid(), the following ASP.NET AJAX's method,
$get('nameofcontrol')
Ex:
var myctrl = $get('lblTotal')


www.codecollege.NET
Blog Widget by LinkWithin