Pages

Sunday, 12 June 2016

Build vs Rebuild vs Clean in .Net

What is difference between Build vs Rebuild vs Clean in .net??


Build solution- if your code file has changed then it will build them.
If your code file has not changed then it won't build.

Rebuild solution- it will build all code files irrespective they are changed or not.

Clean solution- Delete code files.


Rebuild =Clean + Build

then What is difference between rebuild and clean + build solution??

If you have solution which contains two projects say p1 and p2.
if you perform Rebuild then first it will clean project p1 then it will build project p1.
after that project p2 will be clean then it will build project p2.

if you perform clean + Build then first it will clean project p1 and p2 then it will build project p1 and p2 respectivly.

Please comment if you like this post and you can give also suggestion.

Friday, 10 June 2016

Unobtrusive Javascript

What is unobtrusive javascript?


When we talk about web application there are two things, one is Presentation and other one is Behaviour.
Presentation is done by HTML and behaviour is implemented using Javascript.

Now take simple example and understand scenario

To create simple textbox we will write following HTML code
/*code*/
(opening angle bracket) input id="btn1" type="Button" value="Click to Run Javascript" (closing angle bracket)

output of above code:


above code will generate simple button.

Now i want to add behaviour to button. behaviour means i want to show alert box when i click on the button.

Following is the code for above scenario:

Here i have added onclick event to button.

output of above code:



If you want to change the behaviour (for e.g onchange event instead of onclick) then you need to modify your presentation code i.e HTML code. so i can separate this presentation and behaviour and make HTML code more clean.

Unobtrusive javascript separates the presentation from the behaviour.


Step 1: Create separate javascript file (myscript.js) and write down following code into myscript.js



Step 2: refer this js file onto your HTML page and final code looks like
Here we have moved onclick event to separate file called myscript.js so our HTML code is now clean and simple.

Output of above code:



If you like this post then please comment and you can also give suggestion to improve this.

Thursday, 9 June 2016

What is need of document.ready() in JQuery?


Here to illustrate the need of document.ready().
we will write jQuery code without document.ready() before the textbox code and let's run.
so we will get output but textbox is empty.


Output of above code:



Why we get empty textbox?
DOm means Document Object Model
It is in-memory representation of your HTML.It is loaded by browser in interpreted manner. Interpreted manner means line by line execution from top to bottom.so in our case script is getting executed before the textbox element code. so textbox is not loaded into memory while executing script that's why we are getting empty textbox.

Then what is the solution for above problem??

answer is use document.ready()

document.ready() means when the final line of HTML is read then DOM is loaded after that fired this action.

Following example shows need of document.ready():

Output of above code:

What is JQuery? and What is difference between javascript and jQuery?

What is JQuery? and What is difference between javascript and jQuery?




Jquery is a resuable javascript library.
JQuery is not mean to replace javascript.JQuery has derived from Javascript. Javascript is a language.

Let's take simple example to understand How JQuery simplifies code.
Following code shows How to display simple text into textbox using Javascript.


Output of above code:


Now take same example and implement it using jQuery

we required to download jQuery file first.
you can donwload Jquery file from this URL.
jQuery File

Jquery syntax starts with $ sign, after that element name like textbox and then action which we want to perform. In our example action is val.

Following code shows How to display simple text into textbox using JQuery.



Output of above code: