How to get set read TextBox value using JQuery: Simple a + b program Thursday, Oct 28 2010 

As we knew that using javascript to read or get or set textbox value is easy but due to JQuery notation novice developers always make mistakes to read textbox value. Here in this article i will show you how one can get set read textbox value or textbox text using JQuery.

To run the example first add a page in your project. Then add three textboxes and one command button to do sum like below:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="jQuery1.aspx.cs" Inherits="jQuery1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="" >
<head runat="server">
    <title>How to read TextBox value using JQuery</title>
    <form id="form1" runat="server">
        <asp:TextBox runat="server" ID="txtFirst"></asp:TextBox>
        <asp:TextBox runat="server" ID="txtSecond"></asp:TextBox>
        <asp:Button runat="server" ID="btn" Text="+" />
        <asp:TextBox runat="server" ID="txtSum"></asp:TextBox>

Now add the below JQuery script which will read two number from txtFirst & txtSecond and set the result into third TextBox:

<script language="javascript">
            $(document).ready(function() {          
                $('#btn').click(function() {

                    // Read First number & 2nd Number from TextBox
                    var $nFirstNum = parseInt($('#txtFirst').val())
                    var $nSecondNum = parseInt($('#txtSecond').val())
                    var $nResult = $nFirstNum+$nSecondNum

                    // Set the result into txtSum TextBox
                    return false;

Now run the page. Hope you will get below interface:

JQuery SUM

Hope now you can read or write value to a TextBox using JQuery easily.



How to know IP address of a client Machine using JQuery Thursday, Oct 28 2010 

It’s very easy to get IP of any machine.

First I was trying to do it using javascript. But I think it was not possible to do so.

Then my friend suggest me to try with jquery. This is my first experience to work with jquery.

I searched on google and I got code for it. It’s just 2 lines code.



alert( “Your IPAddress is : ” + ipadd.ip);

Easy ???

Don’t forget to add reference of JQuery file.