Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / May 2005

Tip: Looking for answers? Try searching our database.

ASP.net Question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mavrick101 - 01 Jun 2005 00:12 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.