JQuery Selectors and CSS Slectors in JQuery || Selecting Elements in JQuery


Jquery supports many different ways to select an element  or elements that should meet all but the most awkward requirements.
The following table shows the lists example of other selection methods you might want to use:
Example selection methods:
Selector
Selected
$(“#div”)
Select a div with ID of div1
$(“#div.standardDiv”)
Select all divs with a class of standardDiv.
$(“.standardDiv”)
Select all elements with a class of standardDiv
$(“#div4 #div5”)
Select a div with ID of div5 nested inside a div with id of div4
$(“#div”)
Select all divs.
$(“.standardDiv”)[0].innerHTML=”hello Naresh”;
Select the first element of a group of divs with class of standardDiv and set innerHTML property to  “hello Naresh”.

CSS Selectors:
In addition to the previous standard selectors, more modern selectors are also available.
The following table shows the lists example of CSS selection methods you might want to use:
CSS Selectors:
Selector
Selected
$(“div:first”)
First div
$(“div:last”)
Last div
$(“div:even”)
Even-numbered divs
$(“div:odd”)
Odd-numbered divs
$(“div:first-child”)
First child element
$(“div:last-child”)
Last  child element
$(“div:nth-child(3)”)
Third child element
$(“a[href^=http://]”)
Any hyperlink starting with the text http://
$(“a[href$=.zip/]”)
Any hyperlink ending with .zip
$(“a[href*=dotnet”)
Any hyperlink with the text dotnet in it
$(“input[type=button]”)[0].innerText=”hello Naresh”
Selects first input element of type button and changes innerText property to “hello Naresh”
$(“:checked”)
Gets all check boxes that are checked
$(“:disabled”)
All disabled elements
$(“:enabled”)
All enabled elements

jQuery also has provides some inbuilt selectors of its own:

jquery selectors:
Selector
Effect
$(“:button”)[0].innerText=”hello naresh”;
Change inner Text property of first button element.
$(“:contains(naresh)”)
All elements containing text naresh
$(“:hidden”)
All hidden elements
$(“:selected”)
All selected elements
$(“:visible”)
All visible elements
$(“div:not(.standardDiv)”)
Select all div elements that do not have a class of standardDiv



What is the difference between ExecuteNonQuery(), ExecuteReader() and ExecuteScalar() methods in ADO.NET || Comparision among Executtion Methods of Command Class


ExecuteNonQuery():
1.will work with Action Queries only (Create,Alter,Drop,Insert,Update,Delete).
2.Retruns the count of rows effected by the Query.
3.Return type is int
4.Return value is optional and can be assigned to an integer variable.

ExecuterReader():
1.will work with Action and Non-Action Queries (Select)
2.Returns the collection of rows selected by the Query.
3.Return type is DataReader.
4.Return value is compulsory and should be assigned to an another object DataReader.

ExecuteScalar():
1.will work with Non-Action Queries that contain aggregate functions.
2.Return the first row and first column value of the query result.
3.Return type is object.
4.Return value is compulsory and should be assingned to a variable of required type.



How to Change button image on MouseHover,MouseLeave and MouseClick in windows forms C#.net || Button Events in Window form C#.net


In this I am showing about to change button image when we mouse hover on button,mouse leave on button and mouse click.

For that take one Form and add one button control from toolbox and add three images as normal Login button name as login_normal  ,mousehover Login button name as  login_hover  and mouseclick Login button image name as login_pressed for changing button images.

Then select button control properties and set image as normal image button.

Then write the following code in different events:


//for changing button image when mouse hover

private void btnLogin_MouseHover(object sender, EventArgs e)
        {
            this.btnLogin.Image = Properties.Resources.login_hover;
            this.Cursor = Cursors.Hand;   //to change cursor symbol

        }

//for changing button image when mouse leave

        private void btnLogin_MouseLeave(object sender, EventArgs e)
        {
            this.btnLogin.Image = Properties.Resources. login_normal ;
            this.Cursor = Cursors.Arrow; //to change cursor symbol
        }

//for changing button image when mouse click

        private void btnLogin_MouseDown(object sender, MouseEventArgs e)
        {
            this.btnLogin.Image = Properties.Resources. login_pressed;
            this.Cursor = Cursors.Arrow; //to change cursor symbol
        }

Then run application and see output with button image changing on mouse hover, mouse leave and mouse click.




How to set Splash Screen to window application with Timer control in C#.net


In this post I am showing about to set SplashScreen to any Windows forms application in C#.net.
For that first take one form name as SplashScreen in that take one picturebox control from toolbox and add any required image to picturebox.
Again take one form name as Login which you want to develop for your application in that add one Timer control set Timer control property Interval as 3000 then write the following code in Login.cs:

public partial class Login : Form
    {
        public Login()
        {
            InitializeComponent();
            Thread th = new Thread(new ThreadStart(SplashScreen));
            th.Start();
            Thread.Sleep(3000);
            th.Abort();
            Thread.Sleep(1000);
        }
        public void SplashScreen()
        {

            SplashScreen sp = new SplashScreen();
            sp.ShowDialog();


        }
}

Run your Login form then first you will get SplashScreen Image then after Login page will come.