Posts

Recursive Function to find the Control in the Parent Controls

Image
Some times we need to find the child control in the parent control's using the loop structure.I have faced this issue many times and got a unique solution to find the child control in the Parent Controls. Recursive Function to find the Controls

Cascading Dropdown in Asp.Net using jQuery

Image
Cascading dropdown is the most common requirement we use to get in the real time world. So mainly beginners feel difficulty in doing this task. I have seen many of my friends and colleagues face this problem. Hope this could help those folks. Normally some folks posting the Question "How to get the Second Dropdown fill based on the first dropdown selection?” The processing of filling the second dropdown based on the first dropdown selection is called "Cascading Dropdown or Filtered Dropdown". Actually the data source I have used is XML file which contains the Country and State. In the source code this XML file is also given please check once you download the source code. Cascading dropdown can be done in many ways out of which I have chosen this using jQuery. I have taken the common example of Country and States. I have taken two Composite types as "Country" and "State" which contains properties as ID, Name. I have given the structure also. ...

Calling the UserControl Event from the WebForm

Image
The main theme behind this article is give the clear idea about the event and the event handling in .NET. An event is a message sent by an object to signal the occurrence of an action. This action caused by the user interaction such as button click,mouse click e.t.c.The Object that send the event is called the event sender. The object that receives the event and respond according to that is called the event receiver. Actually in communication between the sender and the receiver ,the sender does not know which method or object will receive the event it raises. The mediator between these two is called “Delegate”. A delegate is a class that can hold a reference to a method .The Delegate class has a signature and it can hold the reference only to the methods that match to its signature. Normally I found the requirement to save the main page data in the user control button click which led me to write this article. Here I have taken a user control which c...

Passing Command Line Arguments Using VS 2010

Image
Command line arguments are helpful to provide those parameters without exposing them to everybody. Even with modern UI, we often need a way to start our programs with specific parameters. Command line arguments are helpful to provide those parameters without exposing them to everybody. When developing with .NET and C# you can get the command line arguments from your Main(string[] Args) function. Args is in fact an array containing all the strings separated by spaces entered in the command line. Suppose we have the application which accepts some command line parameters to do some operations.We know how to pass the parameters from command prompt.I have that also some sample here. using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication2010 {      class CommandLineArgument     {           static void Ma...

Factorial Program using C#

This is the basic program for the beginners. Here's how to f ind the factorial of 3. Mathematically it follows like th is 3*2*1=6 class FactorialProgra m     {           static void Main ( string [] args)         {             var fp = new FactorialProgra m();            Console . Write ( "\n Enter the number:\t" );             var result = fp.fact( int . Parse ( Console . ReadLine ()));            Console . WriteLine (result);            Console . ReadLine ();         }           in...

How to Clear the Textbox Text using C#?

This is one of the common requirement we get in our projects.Text box has a wonderful method called " Clear ".This method is used to clear the text in the Text box.I have given a simple example to explain this .I have implemenetd a common method to clear the Text of few Controls .One of that is Textbox. void ClearInputs(ControlCollection ctrls) { foreach (Control ctrl in ctrls) { if (ctrl is TextBox) ((TextBox)ctrl).Text = string .Empty; ClearInputs(ctrl.Controls); } }   You can call this method where ever you want to clear the Text from the Textbox. For more information please click this link TextBox       Hope this would help the beginners. Cheers.

Frame the SQL Query using String Function Format()

The main idea behind this FAQ is to frame our SQL Query using String Format Function. I think this is one of the best way to frame the SQL Query that i found. *** This code introduces SQL injection attacks and should not be used. *** The string.Format method is a static method that receives a string that specifies where the following arguments should be inserted, and these are called substitutions. In source code we need to use to frame the SQL Query public bool SaveData( string firstName, string lastName)     {           String connectionString = ConfigurationManager. ConnectionStrings [ "TESTDB" ]. ConnectionString ;          bool result = false ;          using ( SqlConnection connection = new SqlConnection (connectionString))         {  ...