Saturday, December 28, 2013

JSON Simple Example using AJAX and JQUERY

Introduction:

Hi, today we going to learn JSON concept using AJAX with jquery in c# coding.
Others basic example of my previous post would be a beneficial for you like OOPS concept, and for more search the topic with the search text in the top of the page.

In my example I have used png format so that you type yourself and learn in a better way.

Description:

Json is a Javascript Object Notation, in which the data can be transferred efficiently with light weight and  subset of javascript programming language.
Now a days for webservices we use json format for fast processing of data.

AJAX   is the art of exchanging data with a server, and updating parts of a web page - without reloading the whole page.

In my example i am using jquery source file from the server " http://code.jquery.com/jquery-1.8.2.js ", you can download and set in your file as browser will show error on offline.

Example:

Create the table in your database as like below, I am using toad sql server for creating in my local host.




Now, create the design code in the aspx page or htm page.







after that now add jquery json format as given below between the script tag as given below,




now in the code behind page, add the following 




Now done, If you like my post show it by liking my post thank you!

here you can view the video of sample program given above,





Monday, December 23, 2013

Extendable textbox using jQuery

Extendable textbox using jQuery (Set Maximum length for multiline textbox)

Introduction:

Here we going to see how using the jquery we can extend the multiline textbox length.
For more search on asp.net search it through the search box provided above.

Description:

We know that the jQuery is the small pre written function using javascript, here I am using jquery1.9.1.js file as a script source.
To use a jquery source file, 
we need to declare the script type and source to give the path of the file.

<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js">
</script>
Above we declare the js source path now we need to open a script tag within that we have to gice our condition function supported by the source js file.

<script type="text/javascript">
here the source file function will be entered
</script>

$(function() 
{
 $('#txt_example').keypress(function(e) {
 var txt = $(this).val();
 if (txt.length > 50) {
 e.preventDefault();
 }
 });
 });
                                                              })

Now on the asp.net page put some asp control.
like
<asp:Textbox ID="txt_example" TextMode="MultiLine" runat="server" ></asp:TextBox>

Now whenever you type in the text box it will stretch upto its maximum value.
For any other clarification comment below.

Tuesday, December 3, 2013

STRING AND STRING BUILDER

STRING AND STRING BUILDER  (C#)

Introduction

               The string and stringbuilder in c# using asp.net and their differences.

Description

          In my previous posts we have seen Oops conceptsSql Data ReaderAdo Objects  here we going to see about the string and stringbuilder and their difference.

String

          The string is a data type object which replaces its value if we use insert, update or append. That means each time it will create a separate memory space for its value in the memory to hold a new value.

Example:

StringBuilder 

             In the stringbuilder the insert, update and append can be performed with the first instance without creating   instance each time.

Example:

                 
Difference between string and stringbuilder 

String
1. Low performance than stringbuilder as it creates instance on every instance.   
2. In string it uses "+"  operator for append.
3. String requires System namespace.

Stringbuilder
1. High performance than string as it doesn't creates instance on every instance.   
2. In stringbuilder it uses append for adding.
3. String requires System.Text namespace.


Normally for small usages we use string
The string builder can be used for the special cases like, when we press print button on the ticket page the response page will be as per the given input that type of requirement we use stringbuilder.

******************************************************