C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Preserving Value of textBox


Posted Date: 20 Aug 2008      Total Responses: 4

Posted By: Purushottam Kumar       Member Level: Bronze     Points: 1


i have two text box and a drop down which autopostback is true now when the page is posted back the value of the textbox is lost i want to preserver the value of the two text box.
what should i do?




Responses

Author: D.Jeya kumar(JK)    20 Aug 2008Member Level: DiamondRating:     Points: 1
Hi,


Did your text box viewstate property is enabled?if not please do it.

regards
JK


Author: Jessica    20 Aug 2008Member Level: GoldRating:     Points: 2
Hi,

other solution is...
on the starting of the postback save the textbox value in the hidden fields and after postback re-assign then to original textbox.

Regards.


Author: jeeva    20 Aug 2008Member Level: SilverRating:     Points: 3
hai

If you have no problem to to change the design means

please

Create a new button near by the dropdownlist and write the code in the button, instead of the dropdownlist code


Author: Jessica    20 Aug 2008Member Level: GoldRating:     Points: 6
Hi

When you postback the page on selectedindexchange of the dropdownlist

CODE BEHIND


protected void btn_list_SelectedIndexChanged(object sender, EventArgs e)
{
hiddenValue1.Value = txt_msg.Text;
hiddenValue2.Value = txt_word.Text;

//do the selectedindex operation here

txt_msg.Text = hiddenValue1.Value;
txt_word.Text = hiddenValue2.Value;
}


HTML


<asp:TextBox ID="txt_msg" runat="server"></asp:TextBox>
<asp:TextBox ID="txt_word" runat="server"></asp:TextBox>
<asp:DropDownList ID="btn_list" runat="server" OnSelectedIndexChanged="btn_list_SelectedIndexChanged"></asp:DropDownList>
<input id="hiddenValue1" runat="server" type="hidden"/>
<input id="hiddenValue2" runat="server" type="hidden" />


Regards.



Post Reply
You must Sign In to post a response.
Next : hello tell me what is the mistake here
Previous : page break in table with C#
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design

internet fax

Contact Us    Privacy Policy    Terms Of Use