Getting Started with Adobe After Effects - Part 6: Motion Blur

Upload Image Close it
Select File

I am Jalpesh Vadgama a Microsoft MVP for Visual C# and BrainBench Certified ASP.NET Developer having more then 6 years of experience in .NET Technology.
Browse by Tags · View All
BRH 79
#.NET 52
C#.NET 48
ASP.NET 4.0 31
VisualStudio 27

Archive · View All
December 2010 16
July 2011 13
April 2011 13
April 2012 12
January 2011 12
June 2011 11
May 2011 11
May 2012 8
February 2013 7
January 2013 7

Jquery and ASP.NET- Set and Get Value of Server control

Sep 9 2011 1:09AM by Jalpesh   

Yesterday one of my reader asked me one question that How can I set or get values from Jquery of server side element for example. So I decided to write blog post for this. This blog post is for all this people who are learning Jquery and don’t know how to set or get value for a server like ASP.NET Textbox. I know most of people know about it as Jquery is very popular browser JavaScript framework. I believe jquery as framework because it’s a single file which has lots of functionality.

For this I am going to take one simple example page which contain two textboxes txtName and txtCopyName and button called copyname. On click of that button it will get the value from txtName textbox and set value of another box. So following is HTML for this.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="Experiment.Index" %>

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

<html xmlns="">
<head runat="server">
    <form id="form1" runat="server">
            <asp:TextBox ID="txtName" runat="server" />
            <Br />
            <asp:TextBox ID="txtCopyName" runat="server"/>
            <Br />
            <asp:button ID="btnCopyName" runat="server" Text="Copy"  OnClientClick="javascript:CopyName();return false;"/>

As you can see in following code there are two textbox and one button which will call JavaScript function called to CopyName to copy text from one textbox from another textbox.Now we are going to use the Jquery for this. So first we need to include Jquery script file to accomplish the task. So I am going link that jquery.js file in my header section like following.

<head >
    <script src=""></script>  

Here I have used the ASP.NET Jquery CDN. If you want know more about Jquery CDN you can visit this link.

Now it’s time to write query code. Here I have used val function to set and get value for the element. Following is the code for CopyName function.

function CopyName() {
    var name = $("#<%=txtName.ClientID%>").val(); //get value
    $("#<%=txtCopyName.ClientID%>").val(name); //set value
    return false;
Here I have used val function of jquery to set and get value. As you can see in the above code, In first statement I have get value in name variable and in another statement it was set to txtCopy textbox. Some people might argue why you have used that ClientID but it’s a good practice to have that because when you use multiple user controls your id and client id will be different. From this I have came to know that there are lots of people still there who does not basic Jquery things so in future I am going to post more post on jquery basics.That’s it. Hope you like it.Stay tuned for more.. Happy programming and Namaste!!
Shout it

Tags: C#.NET, #DOTNET, #ASP.NET, JavaScript, ASP.NET, jQuery,

15 · 11% · 3548


Your Comment

Sign Up or Login to post a comment.

"Jquery and ASP.NET- Set and Get Value of Server control" rated 5 out of 5 by 1 readers
Jquery and ASP.NET- Set and Get Value of Server control , 5.0 out of 5 based on 1 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]