TipsOnLips.net

Your .net tips and tricks source

About the author

Author Name is someone.
E-mail me Send mail

Recent comments

Authors

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010


Create Event in C#

Using EventHandler

Declaration: 

        public event EventHandler UserSaved;

        public void OnUserSaved()

        {       

            if (UserSaved != null)       

            {       

               UserSaved(this, EventArgs.Empty);       

            }       

        }   

 

Event Trigger with parameter:

public void OnCustomerSelected(string customerBusinessKey)          
         {             
 
if (!this.CustomerSelected.IsNotNull()) return
;             
 
var e = new CustomerEventArgs

                 {

                  CustomerBusinessKey = customerBusinessKey

                 };             
         

      this.CustomerSelected(this, e);         

          

}


Using Delegate

public delegate void CreateUserControlValidated(object sender, ValidationEventArgs e);

public event CreateUserControlValidated Validated;

 

public class ValidationEventArgs : EventArgs

{

    public virtual IList<string> ClientExceptionList { get; set; }

}

 

Useful Articles: 1


Categories: C#
Posted by Admin on Friday, April 03, 2009 11:02 AM
Permalink | Comments (0) | Post RSSRSS comment feed

C# ParseTry - HowTo

private int IsIntegerInCSharp(string intString)
{
    int intReturn;
    if (!Int32.TryParse(intString, out intReturn))
    {
        throw new Exception("Invalid integer");
    }
    return intReturn;
}

 


Categories: C#
Posted by Admin on Thursday, March 19, 2009 3:03 AM
Permalink | Comments (0) | Post RSSRSS comment feed

ASP.NET Ajax Articles

  1. Implement ASP.NET AJAX with the UpdatePanel control
  2. Creating a Simple ASP.NET Page with Multiple UpdatePanel Controls
  3. UpdatePanel Tips and Tricks
  4. ScriptManager Enables AJAX In Your Web Apps
  5. Drag and Drop with ASP.NET AJAX
  6. New AJAX Support For Data-Driven Web Apps
  7. AJAX Application Architecture, Part 1
  8. AJAX application architecture, Part 2
  9. Managing the User Experience in AJAX
  10. Lazy Loading the ASP.NET AJAX TabContainer Control 
  11. More Sample AjaxControlToolkit TabContainer Themes
  12. ASP.NET AJAX TabContainer – Tips and Tricks 
  13. How To: Lazy-load TabPanel's within the AjaxControlToolkit's TabContainer Control
  14. Delay Load an UpdatePanel
  15. Customize Controls with AJAX Extenders
  16. Modal Dialog Boxes with AJAX
  17. Drag and Drop with ASP.NET AJAX
  18. Creating Sophisticated Animations with the Microsoft AJAX Library
  19. ASP.NET AJAX Extender for multicolumn drag and drop
  20. The Ever-Useful $get and $find ASP.NET AJAX Shortcut Functions
  21. Documentation for: ASP.NET Ajax Version Ajax 1.0,  MSDN1 & MSDN2
  22. Delayed Content Loading Using the AJAX.NET Timer and UpdatePanel
  23. ASP.NET/ AJAX Page Loader Progress Bar/ Splash Screen

Categories: Ajax | ASP.NET | C#
Posted by developer on Wednesday, March 18, 2009 9:04 AM
Permalink | Comments (0) | Post RSSRSS comment feed

ASP.NET RegisterStartupScript - HOW-To

if (!this.Page.IsClientScriptBlockRegistered("hideMessage"))
{ this.Page.RegisterStartupScript("hideMessage", 
	"<script>document.getElementById('" + pnlMessage.ClientID + "').style.display = 
				 'none'</script>;"); }


Categories: ASP.NET | C# | CSS | HowTo | JavaScript
Posted by Admin on Wednesday, March 18, 2009 7:57 AM
Permalink | Comments (0) | Post RSSRSS comment feed

ASP.NET Disable Submit Button on Click - C#

protected override void OnInit(EventArgs e)
{
    btnSearch.Attributes.Add("onclick", "javascript:" + btnSearch.ClientID + ".disabled=true;" 
			+ this.Page.GetPostBackEventReference(btnSearch));
    base.OnInit(e);
}

or

Disable ASP Button on Submit and capture the PostBack OnClick Event


Categories: ASP.NET | C#
Posted by Admin on Sunday, March 15, 2009 3:21 AM
Permalink | Comments (0) | Post RSSRSS comment feed

ASP.NET Error Handling Resources - C#

  1. ASP.NET Custom Error Pages
  2. Error Handling in ASP.Net Ajax Applications
  3. Handling exceptions in ASP.NET Ajax
  4. Asp.net Ajax Exception Logging
  5. How to improve ASP.NET AJAX error handling
  6. Asynchronous error handling change in ASP.NET AJAX 3.5
  7. ScriptManager - AsyncPostBackErrorMessage Property
  8. Tip/Trick: Handling Errors with the UpdatePanel control using ASP.NET AJAX
  9. Error Handling in ASP.NET
  10. Sys.WebForms.PageRequestManagerParserErrorException - what it is and how to avoid it
  11. Configuring Visual Studio to Debug .NET Framework Source Code
  12. ELMAH: Error Logging Modules and Handlers for ASP.NET (and MVC too!)

Tags:
Categories: Ajax | ASP.NET | C#
Posted by developer on Friday, March 13, 2009 4:43 AM
Permalink | Comments (0) | Post RSSRSS comment feed

Loop through an ASP.NET Page controls using the T way

public static T FindControl<T>(this Control control, string controlId) where T : Control
{
    return (T)control.FindControl(controlId);
}

 


Categories: ASP.NET | C#
Posted by Admin on Wednesday, March 11, 2009 7:56 AM
Permalink | Comments (0) | Post RSSRSS comment feed

C# String Split

1)    char[] delimiterChars = { ':'};
       string[] args = t.Split(delimiterChars);

2)    string[] args = t.Split(new char[] {':'});


Categories: C#
Posted by developer on Tuesday, March 10, 2009 3:20 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Nullable object must have a value (C#)

If we assign a nullable object like DateTime to null like below,

nextRunDateTime = null;
DateTime? time = nextRunDateTime.Value;
We get an error of, Nullable object must have a value.
 
But if we use the same example above without the Value object:
nextRunDateTime = null;
DateTime? time = nextRunDateTime;
 
Then no error is generated

Categories: C#
Posted by Admin on Friday, December 05, 2008 4:17 AM
Permalink | Comments (0) | Post RSSRSS comment feed

C# || and && operators

|| Operator

x || Y (if x is true, y is not evaluated (because the result of the OR operation is true no matter what the value of y might be). This is known as "short-circuit" evaluation).

In other words, if x is false, then evalute y.

&& Operator

x && y (if x is false, y is not evaluated (because the result of the AND operation is false no matter what the value of y may be). This is known as "short-circuit" evaluation).

In other words, if x is true, then evalute y.


Categories: C#
Posted by developer on Thursday, November 27, 2008 2:50 AM
Permalink | Comments (0) | Post RSSRSS comment feed