clearing input field after executing button click

Asked By srujan
09-Sep-10 06:20 AM
Earn up to 0 extra points for answering this tough question.
Hi friends
    Iam using input field for entering date....... For this iam using date picker control........It is fine, after clicking on any button in the page its working but the problem is after executing the button click event that my date field is clearing....... how can i solve this problem...........
After button click event other textboxes r not clearing except this date field.........even i dint clear the date field....
so friends please help me............


Thanks & Regards
Sujju

  re: clearing input field after executing button click

harsh shah replied to srujan
09-Sep-10 07:09 AM
Hi,

After successfull execution of your button event u have clear the text box. it's not automatically clear.

For Example:-

Textbox1.text="";

if u want to clear lable then write.
label1.text="";



Regards,
Harsh Shah

  re: clearing input field after executing button click

srujan replied to harsh shah
09-Sep-10 07:20 AM
 No Sir,
        I dont want to clear the input field.......... date field is clearing after executing button click event.........
I want the date wat i selected before button click......... for this iam again entering the date field whenever i click on the button......... means the date field is automatically reseting........ i think now u got my point............ any way thanks for replying sir

  re: clearing input field after executing button click

Sagar P replied to srujan
09-Sep-10 07:24 AM
Check EnabledViewState of that textbox. If its false then it will clear on each postback otherwise it should not clear the contents.
Also check your code. I think something there in your code you have clear it.... may be on page load...
  re: clearing input field after executing button click
[ Kirtan ] replied to srujan
09-Sep-10 07:27 AM

Add runat="server" in Input Field in Aspx code


 <asp:Calendar ID="Calendar1" runat="server" 
      onselectionchanged="Calendar1_SelectionChanged"></asp:Calendar>
    <input runat="server" id="Text1" type="text" /><br />
    <asp:Button ID="Button3" runat="server" Text="Button" />
  re: clearing input field after executing button click
harsh shah replied to srujan
09-Sep-10 07:43 AM
ok
set the enable viewstate = true;
it solve the issue
if not solve with this method

then on button click take your date value in a session and then after execution of button fill session value into the textbox on page load.

for example:

on button click

session["Date"]=txtdate.text.tostring();

on page load

if(session["Date"]!="")
{
txtdate.text=session["Date"].tostring();
}


let me know
Regards,

Harsh Shah
  re: clearing input field after executing button click
sana replied to srujan
06-Feb-11 02:26 AM
i just saw ur post and i dont know u find the solution or not..this prob occurs due to postback prob..on every click event the page is refreshed and so the Page_Load func is called so controls like datetime picker,dropbox,checkbox etc selection are cleared... so use

if (!Page.IsPostBack)
{
     //set ur initial value in date time picker here
}

it should work
Create New Account