GlobaLevel
asked on
ASP.NET/Javascript - TextArea deletes data on Postback...
I have a textarea on my vb.net page...but when the page autopostabacks...the data in the textarea is gone...is there a way to keep this data...the user gets frustrated that all their data is gone..and they have to retype...Jsession varable javascript anwser?
use Viewstate for retaining the data on postbacks
set the attribute EnableViewState=true. i hope this will be enough...
Textarea is HTML Control and viewstate will not be applicable. You need to get/set the value manually
Like, document.getElementById('< %=TextArea 1.ClientID %>').value
http://forums.asp.net/p/1632813/4209700.aspx
A Sample in PHP
<textarea cols="50" rows="5" name="descr"><?php echo $_POST['descr'];?></textar ea>
Like, document.getElementById('<
http://forums.asp.net/p/1632813/4209700.aspx
A Sample in PHP
<textarea cols="50" rows="5" name="descr"><?php echo $_POST['descr'];?></textar
ASKER
thanks all..but Im using asp.net...anyone else...actual code?
ASKER
okay so the hiddenfield is not quite working here....
window.onload = function () {
// sessionDuration = document.getElementById("<%= sessionDuration.ClientID %>").value;
document.getElementById("<%= txtTextbox2.ClientID %>").innerHTML = document.getElementById("<%= attendant_name.ClientID %>").value
document.getElementById("<%= textarea2.ClientID %>").innerHTML = document.getElementById("<%= attendant_name1.ClientID %>").value
document.getElementById("<%= textarea3.ClientID %>").innerHTML = document.getElementById("<%= attendant_name2.ClientID %>").value
document.getElementById("<%= textarea4.ClientID %>").innerHTML = document.getElementById("<%= attendant_name3.ClientID %>").value
document.getElementById("<%= textarea5.ClientID %>").innerHTML = document.getElementById("<%= attendant_name4.ClientID %>").value
}
ASKER
its saying these controls are not declared...
>>document.getElementById( "<%= attendant_name.ClientID %>").value -
if this is a client side normal html hidden field u can directly access it by
document.getElementById('a ttendant_n ame').valu e
those <%= %> are needed only for server controls
if this is a client side normal html hidden field u can directly access it by
document.getElementById('a
those <%= %> are needed only for server controls
You just try with
if (!IsPostBack)
{
String example = textbox1.Text;
}
ASKER
so this will work to retain the user data on form refresh in Text area:
if is postback then
<%textarea1.clientid%>.val ue = document.getElementById('a ttendant_n ame').valu e
end if
if is postback then
<%textarea1.clientid%>.val
end if
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.