Hi,
I have an ASP.net page. After submitting the form and saving all the form
values I want to give user an option to enter more records ( like reloading
the page with empty fields and clear viewstate)
Is there a way to clear the Page of the existing values or do I have to do
it manually (control by control)
Thnx
Ryan Ternier - 01 Jun 2005 00:21 GMT
> Hi,
>
[quoted text clipped - 6 lines]
>
> Thnx
The easiest way would be to just use:
Response.Redirect("yourPage.aspx");
That way it's not a postback.
IntelYogi - 01 Jun 2005 00:22 GMT
Hi Mavrick ,
I don't think there is inbuilt stuff for clearing the form fields.
U can write an function to clear the form Collections. In that way u don't
need to clear one by one.
here the code snippet which might help you to iterate thru the form
collections on server side
private void clearFormControls(){
int ctlCount=Convert.ToInt32(Page.Controls.Count.ToString());
int i;
TextBox tempText = new TextBox();
ListBox templist = new ListBox();
for (i=0; i<amtControl; i++)
{
switch (Page.Controls[i].GetType())
{
case tempText.GetType():
((TextBox) Page.Controls[i]).Text = "";
break;
case templist.GetType():
((ListBox)Page.Controls[i]).Items.Clear();
break;
default:
break;
}
}
}
In the above define your all page controls whatever u have defined and
accordingly clear i.e dropdown etc and call the clearControls function in
your save routine
U can also write and client javascript function to clear the form
collections and mode of submit and check it in onload if the mode is submit
and success clear the controls
Hope this helps you
Thanks
IntelYogi
> Hi,
>
[quoted text clipped - 6 lines]
>
> Thnx