Click here to Skip to main content
12,506,198 members (53,913 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# ASP.NET
- I have written a piece of code in which i have declared 2 text boxes. I have set one of the text box's autopostback property to true and the others to false.
-I have wired up both the textbox's changetextevent to the same eventhandler.
-I have also defined a label control which will display the changed text of the textbox when the text of the textbox control changes.
-Now When i change the text of the first text box whose autopost back property is true, the text in the label changes, if i do the same for the second textbox then nothing happens.
-Now if i once again change the text of the 1st textbox (autopostback = true) then the label gets assigned to both the textbox

Here is the code snippet:

<asp:TextBox ID="auto_true" AutoPostBack="true" OnTextChanged="changetext" runat="server" />;
<asp:TextBox ID="auto_false" AutoPostBack="false" OnTextChanged="changetext" runat="server" />;
<asp:Label ID="label_textbox" runat="server" Text="Changed_Data"/>;



Code Behind :

protected void Page_Load(object sender, EventArgs e)
{

label_textbox.Visible = false;
label_textbox.Enabled = true;

}

public void changetext(object sender, EventArgs e)
{
if (!label_textbox.Visible)
{
label_textbox.Visible = true;
label_textbox.Text = auto_true.Text;
label_textbox.Text +=auto_false.Text;

}

}


Note: Please ignore some special charecters if you encounter them, they are added by default while displaying
Posted 25-Jul-13 22:39pm
Rahul VB5.2K
Updated 25-Jul-13 22:44pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160927.1 | Last Updated 26 Jul 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100