.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Get Value From Textbox Before PostBack

Posted By:      Posted Date: April 14, 2011    Points: 0   Category :ASP.Net

I've coding a banking system for one of the courses @ our school in ASP.NET and on my form I've got a dropdownlist, selectable gridview that populates a label, a textbox for whatever amount the transaction is, and a submit button. Now it would be easy enough to add a "Are you sure" confirmation button but I need to display a summary of the transaction so I've been creating the message in the background on each postback and populating the .OnClientClick property of the button (cmdProcess.OnClientClick = "return confirm('" + BuildCmdProcessConfirmationString() +

View Complete Post

More Related Resource Links

textbox not writable after partial postback of updatepanel

hi, i got a strange problem. my project was ok before implimenting ajax. i have just implimented ajax in one page only with Tabcontainer and updatepanels only nothing else. almost all controls are devided into different Tabs with respective update panels. mostly it is working ok. but the problem is : 1.   in some controls i am not able to write anything even the control is "Enabled=True" and focus is on the same control after partial postback. 2.   and as soon as i press Tab control goes to Address bar. 3.   some time tab key is also not working.Why ? here some code :<td style="width: 57684px; text-align: left">                                                Inception Date (dd-mm-yyyy)</td>                                            <td style="width: 604px; text-align: left">              &n

Can't access dynamicly created textbox in AJAX postback.


I have a script which creates a dynamic textbox (and more) in an AJAX async post back. But when I try to acess the textbox I am told "Object reference not set to an  instance of an object". I have been strugleing with this for a long time and can not get it to work so please help me. This is written in C# .Net 4. The line causing the problem is the very last one where I have tbGameName.Text.Trim()

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class GameInformation_AddUpcomingRelease : System.Web.UI.Page
    protected override void OnInit(EventArgs e)
        string v = this.Request.Params.Get(this.ddlAmountToAdd.UniqueID);

        string[] Regions = { "USA", "Japan", "Europe", "Other" }; //Create a string array of regions.
        string[] Platforms = { "PlayStation 3", "X-Box 360", "Wii", "Computer", "PSP", "Other" }; //Create a string array of platforms

        CreateControlSet(1, Regions, Platforms); //Generate the first Control Set

        if (!string.IsNullOrEmpty(v))
            for (byte i = 2; i <= Convert.ToByte(v); i++)
                //Add a

How do you get a textbox/input or a javascript to postback?


I am using a Yahoo UI dual slider.  The dual slider changes values based on what you slide.  It uses javascript and sends this value back to a Input type="text" textbox. 

I want to be able to do a automatic postback and call the server function "protected void zoom(object sender, EventArgs e)"  each time the slider value changes.

So what I did was:

<asp:TextBox type="text" id="demo_from"  runat="server"
OnTextChanged="Zoom" AutoPostBack="true">

But the problem is, it WILL not fire the server-side event unless I manually click the textbox and press "ENTER".  Then the event will fire (during debug).

So how can I get the event to auto-fire each time the slider value changes?


Textbox loses its value after postback


There is button(btnOpen) and a textbox (txtResult) in the page. 

Once I clicked on btnOpen, a modal dialog will appear, displaying TextBox1 and Button1.

The user is required to type something in TextBox1 and I want to pass the TextBox1.Text into my database but when I try to do that, the value actually = "", which is gone. 

So I created this test program to illustrate by passing the value into a txtResult. 

Can anyone guide me on getting the TextBox1.Text value?

Besides that, is there anyone to tell more about what does this lines of code do?

$("#Button1").click(function () {
                <%=this.Page.ClientScript.GetPostBackEventReference(new PostBackOptions(this.Button1))%>;

The aspx code:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication10.WebForm1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">

    <link href="Styles/jquery-ui-1.8.5.custom.css" rel="stylesheet" type=&

Update textbox without postback


I have a simple page with 2 textbox: tb1, tb2.

When tb1 text is changed I would like to update tb2 (for example with the text of tb1), without postback the page (in javascript).

I know this question is very simple, but I'm quite new in asp.net.


Textbox that is enabled by javascript not retained on postback


In my page, I need to enable a text box when user click on check box(checked). I have used javascript for this. It works fine but when there is postback for the page, the textbox becomes disabled again although the check box is checked. But the value in textbox still appears. Is there any method to retain the enabled state for text box on postback other than using hidden values?

Textbox Editable GridView in ASP.NET

This article describes how I made a fully editable gridview in C# using ASP.NET 2. The idea is that the GridView looks and works like an Excel spreadsheet. You see all the cells in the table, and you can edit any of the cells you like, and they are automatically updated (i.e. saved to the database). This is very often how people expect data tables to work in web pages, and I've often seen people clicking in vain on un-editable gridview cells, somehow expecting to edit them, and not understanding that they need to click an Edit button at the end of the row.

jQuery $(document).ready() and ASP.NET Ajax asynchronous postback

Many call it the ASP.NET jQuery postback problem, but using the technique below should make it no problem anymore. $(document).ready() isn't called after an asynchronous postback. What this means? You lose the functionality that should be executed within $(document).ready() after an UpdatePanel rendered its contents after an asynchronous postback.

Highlighting Rows with TextBox OnFocus

In another article I explained that how you can make the rows of the GridView control clickable and highlight them when they are clicked. In this article I will explain that how you can highlight the GridView rows when you focus on the TextBox which is contained inside the GridView control.

jQuery live() and ASP.NET Ajax asynchronous postback

The issue is that normally $(document).ready() is called when the DOM is ready to be manipulated. But this doens't happen after an ASP.NET Ajax asynch postback occurs.

This means that the initial jQuery bindings won't be automatically available after the asynchronous postback is over. I underline "automatically" here because my last post describes more possibilities, how this issue can be worked around.

Maintain HTML Radio Button Selection Inside GridView After Postback

Long time ago I wrote an article about getting the value of the selected RadioButtons inside the GridView control. The code did not addresssed the postback issue which means that the selected radio button was cleared after the postback occurs.

Custom Editing Behavior for DataGridView TextBox Columns

For various reasons I'm using a DataGridView instead of a ListView, and while configuring the DataGridView to look like a ListView wasn't much of a problem, there's one thing that got on my nerves, which is the behavior of textbox cells in edit mode: It is much too easy to leave the edit mode accidentally, simply by pressing the cursor keys at the wrong time. For example when the text caret is positioned behind the last character of the textbox cell content, and you press the right arrow key

Editable Gridview with Textbox, CheckBox, Radio Button and DropDown List

This is an example of an editable gridview containing different ASP.NET controls. When user wants to edit values in gridview, she/he can use these controls to edit existing values in Gridview Edit Mode.

Using the Code

watermark textbox using Ajax control

This is pretty simple compared to jquery. Since we need refer a dll only. we dont want any script for this. we just include that reference into our website.

How to take value of bound field of grid in a variable or in a textbox.


How to take value of bound field of grid in a variable or in a textbox.

 I m using this code in .aspx page for grid.

<asp:GridView ID="Grd_Mprocess" runat="server" AutoGenerateColumns="False"

                      Width="100%" AllowPaging="True"


                      AllowSorting="True" PageSize="5"  >

                 <RowStyle CssClass="odd" />


<asp:BoundField HeaderText="DOC_TYPE_PK" DataField="DOC_TYPE_PK"  Visible="true" >


  <asp:TemplateField HeaderText="DOC TYPE ID" Visible="true">  &nbs

Textbox in ItemTemplate inside Gridview, unable to get the value


Hi. I have a itemtemplate inside a gridview.

<asp:TemplateField HeaderText="Enter OTP">
                            <asp:Label ID="Label2" runat="server"
                                style="font-family: Arial, Helvetica, sans-serif; font-size: x-small"
                                Text="PIN Num:"></asp:Label>
                            &nbsp;<asp:TextBox ID="txtPIN" runat="server" Height="21px" Width="100px"></asp:TextBox>

pass value from textbox to action, formcollection best way here?


Hi I'm building a e-commerce store and on quantity of product I'm going with a textbox. I thought I would ask how would you do this? a viewmodel to use a strongly typed textbox or just get the value of the textbox from the formscollection passed in to the action?

Thanks for any input

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend